Bug 62661 - digit separator warning in if'ed out code
Summary: digit separator warning in if'ed out code
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
: 101628 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-09-01 20:47 UTC by Oleg Endo
Modified: 2022-12-08 12:30 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-11-25 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg Endo 2014-09-01 20:47:12 UTC
Compiling the following snippet as C or C++ < C++14:

#if 0
unsigned int test (void)
{
  return 0b0101'0101'0101'0101'0101'0101'0101'0101;
}
#endif

results in the following warning:

warning: missing terminating ' character
   return 0b0101'0101'0101'0101'0101'0101'0101'0101;
                                              ^

Putting the code in a block comment makes the warning go away.
I'm not sure how to categorize this or whether this is intended.  It looks strange though.
Comment 1 Andrew Pinski 2014-09-01 21:35:46 UTC
This is correct tokenization has to happen in #if code.

*** This bug has been marked as a duplicate of bug 11806 ***
Comment 2 Jonathan Wakely 2015-11-25 11:40:51 UTC
(In reply to Andrew Pinski from comment #1)
> This is correct tokenization has to happen in #if code.

But in C++14 tokenization should handle digit separators, see the definition of pp-number in 2.9 [lex.ppnumber], which allows single quotes in a pp-number.
Comment 3 Andrew Pinski 2016-08-01 06:05:12 UTC
(In reply to Jonathan Wakely from comment #2)
> But in C++14 tokenization should handle digit separators, see the definition
> of pp-number in 2.9 [lex.ppnumber], which allows single quotes in a
> pp-number.

Right it does not warn for C++14 and above so there is no bug and even was mention in the original comment:
C or C++ < C++14
Comment 4 Richard Biener 2021-07-27 11:04:19 UTC
*** Bug 101628 has been marked as a duplicate of this bug. ***
Comment 5 Andrew Pinski 2021-10-15 20:25:11 UTC
Similar issue as PR 11064.
Comment 6 Jonathan Wakely 2022-12-08 12:25:08 UTC
What's really fun is that you can't even do:

#if __cpp_digit_separators
int i = 1'000;
#else
int i = 1000;
#endif
Comment 7 Jakub Jelinek 2022-12-08 12:30:58 UTC
I think it is PR14634 that actually changed this.
The question is if we can avoid the pedwarn in system headers, or if it should be kind of pedwarn that isn't emitted as a warning without -pedantic/-Wpedantic.