This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/60517] warning/error for taking address of member of a temporary object
- From: "lopezibanez at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 25 Jul 2017 17:49:15 +0000
- Subject: [Bug c++/60517] warning/error for taking address of member of a temporary object
- Auto-submitted: auto-generated
- References: <bug-60517-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60517
--- Comment #24 from Manuel López-Ibáñez <lopezibanez at gmail dot com> ---
How does typeck.c check that it is a temporary? The important thing is not
that it is an ARRAY_REF but that it is a member of a temporary object. Not
sure how to check that.
Marc points above that the FE introduces a clobber to mark the death of the
temporary, so it knows.
The problem of warning for artificials is that optimization passes create
and read uninitialized memory if this provides an advantage and it doesn't
change the behaviour of the code. Warning about those would be very
annoying, if the user code is correct.