__LINE__Authors: Jay Ghiron
Date: 2026-03-05
Submitted against: C23
Status: Open
Cross-references: 0464, 1016
Issue 1016 was resolved as not allowing digit separators
in __LINE__. However, there are other issues with the permissible
spellings of __LINE__. Specifically relating to #line __LINE__ as
mentioned in DR 464. First, if __LINE__ expands to a
binary constant or a hexadecimal constant then #line __LINE__ is
invalid. Second, if __LINE__ expands to include an integer suffix
then #line __LINE__ is also invalid. Third, if __LINE__ expands
to an octal constant then #line __LINE__ will possibly result in a
different value. For example:
//line 1
//line 2
//line 3
//line 4
//line 5
//line 6
//line 7
#line __LINE__
__LINE__
As indicated in DR 464, this could expand to eight or
nine. However if an octal constant were used, this could instead
expand to ten or eleven. Since #line 010 is interpreted as setting
the line number to ten, not eight.
Is it intended that #line __LINE__ must be valid?
Is it intended that #line __LINE__ cannot have more than two
possible results due to octal constants possibly being used?
Outside of #line __LINE__, should the spelling of __LINE__ be
strictly defined so that stringization and concatenation have well
defined results? For example:
#define CAT(X,Y,...)__VA_OPT__(X)##__VA_OPT__(Y)
#define DEFINE int CAT(v,__LINE__,,);CAT(v,__LINE__,,)=42
int main(){
DEFINE;
}
There are many programs like this that rely on the spelling of
__LINE__ being consistent within a line. See also C++ CWG
3142.