[Bug preprocessor/120778] [C++26] P2843R3 - Preprocessing is never undefined
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Aug 7 06:54:29 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120778
--- Comment #12 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:2c5bd8e9fb16584cdd1d090b9a5a63dd9140b61b
commit r16-3060-g2c5bd8e9fb16584cdd1d090b9a5a63dd9140b61b
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Aug 7 08:51:00 2025 +0200
c++: Add testcase for CWG2576 [PR120778]
Another part of the C++26 P2843R3, this time in
https://eel.is/c++draft/cpp.include#7
changing former (compile time) undefined behavior to IFNDR.
With IFNDR we wouldn't have to test anything I guess, but this still adds
the cases from the 3.4 section of the paper plus related tests.
The paper wonders about implementation divergence between most compilers
and
gcc in the case of glueing tokens together with <> around from multiple
macros, GCC doesn't add CPP_PADDING macros in that case (and even if it
would, it would ignore them through get_token_no_padding).
But I think this behavior is allowed by
https://eel.is/c++draft/cpp.include#7.sentence-3
and changing it now after 25+ years of such behavior might break real-world
stuff, especially making it really hard to construct the <> includes from
some name and adding < and > from some other macro around that. We handle
#define A <cstd def>
#include A
like clang++ and try to open 'cstd def' file. But not adding spaces for
all the padding means handling even stuff where nothing else can help,
while for cstd def coming from different macros one can use token pasting
to combine them together, e.g. < and following identifier or identifier
followed by . or . followed by identifier or identifier followed by > can't
be pasted together.
2025-08-07 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/120778
* g++.dg/DRs/dr2576.C: New test.
More information about the Gcc-bugs
mailing list