[Bug c/108054] C2X auto with struct defined in statement expression
joseph at codesourcery dot com
gcc-bugzilla@gcc.gnu.org
Tue Dec 13 01:30:20 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108054
--- Comment #2 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
The basic principle is that auto declarations should always be writable in
a form without auto, so they should never result in a type escaping to a
larger scope (but a rule expressed in that form would be very complicated
to check, as discussed in the context of earlier drafts of the auto
proposal with a rule expressed in such terms, hence the current version).
Thus examples like these, where the type declared in a statement
expression does escape via the type of that expression, are entirely
appropriately rejected.
For cases of non-ordinary identifiers declared in code using only standard
constructs (not all of which are properly detected by GCC at present), and
related issues for some cases other than auto, I provided BSI with a
document c2x-declaration-context.pdf to include when submitting the NB
comments I provided on the C2X CD to ISO, which gives 16 examples of code
using such corner cases and discusses what general principles might be
consistent with the interpretations previously applied by WG14 in some of
those cases. So hopefully that will be included with the CD ballot
results, if BSI includes that document as requested.
More information about the Gcc-bugs
mailing list