public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49803] New: [C++0x] erroneous variant-member initialization in a union containing an anonymous struct
@ 2011-07-21 9:18 fuchsia.groan at virgin dot net
2011-08-02 15:03 ` [Bug c++/49803] " redi at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: fuchsia.groan at virgin dot net @ 2011-07-21 9:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49803
Summary: [C++0x] erroneous variant-member initialization in a
union containing an anonymous struct
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: fuchsia.groan@virgin.net
/* The output of this code should be 'Y'. But define SHOW_BUG and it becomes
X: */
#define SHOW_BUG
#include <cstdio>
struct X
{
X() : m_value {'X'} {}
char m_value;
};
union Y
{
// N3291=11-0061 12.6.2/8 says no initialization of
// of other variant members (i.e. m_x) should
// be performed.
Y( char c )
: m_char1{ c }
{ }
#ifdef SHOW_BUG
struct
{
#endif
char m_char1;
#ifdef SHOW_BUG
};
#endif
X m_x;
};
int main()
{
Y y ( 'Y' );
printf( "%c\n", y.m_char1 ); // expected 'Y', get 'X'...
return 0;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/49803] [C++0x] erroneous variant-member initialization in a union containing an anonymous struct
2011-07-21 9:18 [Bug c++/49803] New: [C++0x] erroneous variant-member initialization in a union containing an anonymous struct fuchsia.groan at virgin dot net
@ 2011-08-02 15:03 ` redi at gcc dot gnu.org
2011-08-02 18:34 ` jason at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2011-08-02 15:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49803
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.08.02 15:03:07
CC| |jason at gcc dot gnu.org
Ever Confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-08-02 15:03:07 UTC ---
Confirmed, this reduced test should not abort but does:
struct X
{
X() { __builtin_abort(); }
};
union Y
{
// N3291=11-0061 12.6.2/8 says no initialization of
// of other variant members (i.e. m_x) should
// be performed.
Y( )
: m_char1{ }
{ }
struct
{
char m_char1;
};
X m_x;
};
int main()
{
Y y;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/49803] [C++0x] erroneous variant-member initialization in a union containing an anonymous struct
2011-07-21 9:18 [Bug c++/49803] New: [C++0x] erroneous variant-member initialization in a union containing an anonymous struct fuchsia.groan at virgin dot net
2011-08-02 15:03 ` [Bug c++/49803] " redi at gcc dot gnu.org
@ 2011-08-02 18:34 ` jason at gcc dot gnu.org
2011-08-02 21:09 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2011-08-02 18:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49803
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |jason at gcc dot gnu.org
|gnu.org |
--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-02 18:33:44 UTC ---
Agreed. But note that the standard doesn't include anonymous structs, so this
is not a pedantically conforming program.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/49803] [C++0x] erroneous variant-member initialization in a union containing an anonymous struct
2011-07-21 9:18 [Bug c++/49803] New: [C++0x] erroneous variant-member initialization in a union containing an anonymous struct fuchsia.groan at virgin dot net
2011-08-02 15:03 ` [Bug c++/49803] " redi at gcc dot gnu.org
2011-08-02 18:34 ` jason at gcc dot gnu.org
@ 2011-08-02 21:09 ` jason at gcc dot gnu.org
2011-08-03 1:29 ` jason at gcc dot gnu.org
2011-08-03 1:29 ` jason at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2011-08-02 21:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49803
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-02 21:09:02 UTC ---
Author: jason
Date: Tue Aug 2 21:08:57 2011
New Revision: 177213
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=177213
Log:
PR c++/49803
* init.c (sort_mem_initializers): Initialize uses_unions_p here.
(build_field_list): Not here.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/union5.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/init.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/49803] [C++0x] erroneous variant-member initialization in a union containing an anonymous struct
2011-07-21 9:18 [Bug c++/49803] New: [C++0x] erroneous variant-member initialization in a union containing an anonymous struct fuchsia.groan at virgin dot net
` (2 preceding siblings ...)
2011-08-02 21:09 ` jason at gcc dot gnu.org
@ 2011-08-03 1:29 ` jason at gcc dot gnu.org
2011-08-03 1:29 ` jason at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2011-08-03 1:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49803
--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-03 01:25:28 UTC ---
Author: jason
Date: Wed Aug 3 01:25:25 2011
New Revision: 177226
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=177226
Log:
PR c++/49803
* init.c (sort_mem_initializers): Initialize uses_unions_p here.
(build_field_list): Not here.
Added:
branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/union5.C
Modified:
branches/gcc-4_6-branch/gcc/cp/ChangeLog
branches/gcc-4_6-branch/gcc/cp/init.c
branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/49803] [C++0x] erroneous variant-member initialization in a union containing an anonymous struct
2011-07-21 9:18 [Bug c++/49803] New: [C++0x] erroneous variant-member initialization in a union containing an anonymous struct fuchsia.groan at virgin dot net
` (3 preceding siblings ...)
2011-08-03 1:29 ` jason at gcc dot gnu.org
@ 2011-08-03 1:29 ` jason at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2011-08-03 1:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49803
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.6.2
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-03 01:27:05 UTC ---
Fixed for 4.6.2.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-08-03 1:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-21 9:18 [Bug c++/49803] New: [C++0x] erroneous variant-member initialization in a union containing an anonymous struct fuchsia.groan at virgin dot net
2011-08-02 15:03 ` [Bug c++/49803] " redi at gcc dot gnu.org
2011-08-02 18:34 ` jason at gcc dot gnu.org
2011-08-02 21:09 ` jason at gcc dot gnu.org
2011-08-03 1:29 ` jason at gcc dot gnu.org
2011-08-03 1:29 ` jason at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).