Bug 123057 - Preprocessing numbers don't recognize dollar signs after digit separators
Summary: Preprocessing numbers don't recognize dollar signs after digit separators
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 16.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2025-12-08 19:37 UTC by Halalaluyafail3
Modified: 2026-07-14 16:11 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.