https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123057
Bug ID: 123057
Summary: Preprocessing numbers don't recognize dollars signs
after digit separators
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: preprocessor
Assignee: unassigned at gcc dot gnu.org
Reporter: luigighiron at gmail dot com
Target Milestone: ---
The following code is incorrectly rejected by GCC:
#define STR(X)#X
int main(){
STR(0'$);
}
C23 optionally allows implementations to support dollar signs in identifiers,
by saying:
> It is implementation-defined if a $ (U+0024, DOLLAR SIGN) may be used as a
nondigit character.
Section 6.4.2.1 "General" Paragraph 2 ISO/IEC 9899:2024
The definition of pp-number refers to nondigit when defining digit separators,
so this should also apply there. MSVC accepts this code, Clang does not. Though
Clang also doesn't accept 0$, which is surely a bug.
I think it also worth mentioning, the definitions of nan(...) in strtod,
wcstod, etc. refer to nondigit hence nan($) should presumably be accepted.
Though that seems more like a bug than the intended behavior. The requirements
of a unique mapping in include directives also mention it, probably unintended
though I don't think any implementations would violate that because of needing
to support dollar signs.