Issue 1082: Dollar signs in nondigits

Authors: Jay Ghiron
Date: 2026-06-17
Submitted against: C23
Status: Open

It is implementation-defined if a $ (U+0024, DOLLAR SIGN) may be used as a nondigit character.

(C23 6.4.3.1 "General" paragraph 2.)

This is intended to allow dollar signs optionally in identifiers, and presumably also preprocessing numbers so that they can be used in concatenation:

#define C(X)X##0$

However, nondigit is used in other places such as n-char-sequence which means that:

#include<stdio.h>
#include<stdlib.h>
int main(){
char*p;
strtod("nan($).",&p);
puts(p);
}

Should have three possible outputs "nan($)." (quiet NaN is not supported in double), "($)." (quiet NaN is supported in double but dollar signs are not allowed in nondigits), and "." (quiet NaN is supported in double and dollar signs are allowed in nondigits). I do not think it was intended for the parsing of nan(...) to be altered by allowing dollar signs in identifiers. nondigit is also referenced in the requirements of a unique mapping in header names, I do not think that meant to possibly include dollar signs.

GCC, Clang, and MSVC disagree about when dollar signs are allowed in preprocessing numbers. See also GCC issue 123057 and LLVM issue 171190.

Suggested correction

Modify C23 6.4.3.1 paragraphs 1 and 2:

identifier-start:

nondigit-identifier

XID_Start character

universal character name of class XID_Start

identifier-continue:

digit

nondigit-identifier

XID_Continue character

universal character name of class XID_Continue

nondigit:

one of

_ a b c d e f g h i j k l m
  n o p q r s t u v w x y z
  A B C D E F G H I J K L M
  N O P Q R S T U V W X Y Z

nondigit-identifier:

nondigit

$ (if supported)

...

It is implementation-defined if a $ (U+0024, DOLLAR SIGN) may be used as a nondigit-identifier character.

Modify C23 6.4.9 paragraph 1:

pp-number:

digit

. digit

pp-number identifier-continue

pp-number ' digit

pp-number ' nondigit-identifier

pp-number e sign

pp-number E sign

pp-number p sign

pp-number P sign

pp-number .

Note: This change keeps 0'$ valid, there does not appear to be any reason to forbid it.

Note: C23 J.5.3 has not been properly updated since initial standardization to consider that XID_Start characters and XID_Continue characters are allowed in identifiers, and that $ is in the basic source character set.