Bug 123057

Summary: Preprocessing numbers don't recognize dollar signs after digit separators
Product: gcc Reporter: Halalaluyafail3 <luigighiron>
Component: preprocessorAssignee: Not yet assigned to anyone <unassigned>
Status: UNCONFIRMED ---    
Severity: normal Keywords: rejects-valid
Priority: P3    
Version: 16.0   
Target Milestone: ---   
See Also: https://github.com/llvm/llvm-project/issues/171190
https://github.com/llvm/llvm-project/issues/209516
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Halalaluyafail3 2025-12-08 19:37:45 UTC
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.