Title
Possible expansions of __LINE__ changing over time
Status
review
Section
15.12 [cpp.predefined]
Submitter
Jiang An

Created on 2025-12-05.00:00:00 last changed 1 week ago

Messages

Date: 2026-01-10.20:04:04

Proposed resolution (reviewed by CWG 2026-01-09):

Change in 15.12 [cpp.predefined] as follows:

__LINE__
An A decimal integer literal (5.13.2 [lex.icon]), with no digit separators and no integer-suffix, representing the presumed line number of the current source line within the current source file. [Note 4: The presumed line number can be changed by the #line directive (15.8). —end note]
Date: 2026-01-10.20:04:04

(From submission #826.)

__LINE__ is specified in 15.12 [cpp.predefined] paragraph 1 as:

The presumed line number (within the current source file) of the current source line (an integer literal).

The spelling of a literal is observable through stringizing (15.7.3 [cpp.stringize]). Furthmore, the set of possible spellings for a literal of a given integer value has expanded over time; for example digit separators and binary integer literals are permitted since C++14.

A program that relies on a particular spelling of an integer literal expanded from __LINE__ might thus break, e.g. when crafting unique identifiers using token concatenation (15.7.4 [cpp.concat]).

We could either add an Annex C entry for this breakage in C++14, or specify that __LINE__ always yields a decimal integer literal with no digit separators.

See also WG14 issue 1016.

History
Date User Action Args
2026-01-10 20:04:04adminsetmessages: + msg8452
2026-01-10 20:04:04adminsetstatus: open -> review
2025-12-05 00:00:00admincreate