public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52915] New: [C++11] Deleted default-constructor of anonymous unions not honored
@ 2012-04-09 16:32 daniel.kruegler at googlemail dot com
  2012-04-12 22:07 ` [Bug c++/52915] " jason at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-04-09 16:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52915

             Bug #: 52915
           Summary: [C++11] Deleted default-constructor of anonymous
                    unions not honored
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com


gcc 4.8.0 20120318 (experimental) in C++11 mode accepts the following code:

//---
struct S {
  int val;
  S(int v) : val(v) {}
};

void f() {
  union { S a; };
}
//---

This seems to violate to what the standard says. According to 9.5 p5:

"A union of the form
  union { member-specification } ;
is called an anonymous union; it defines an unnamed object of unnamed type."

combined with 12.1 p5 b6:

"A defaulted default constructor for class X is defined as deleted if:
[..]
— any [..] non-static data member with no brace-or-equal-initializer, has class
type M [..] and [..] M has no default constructor [..]"

The last item has the effect that the anonymous union defined in f() is a
union-like class that has a deleted default constructor, but the definition in
f() also defines an unnamed object of that type which is default-initialized.
It seems that gcc does not respect the last part of the semantics of this
declaration.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-04-13 19:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-09 16:32 [Bug c++/52915] New: [C++11] Deleted default-constructor of anonymous unions not honored daniel.kruegler at googlemail dot com
2012-04-12 22:07 ` [Bug c++/52915] " jason at gcc dot gnu.org
2012-04-13 19:47 ` jason at gcc dot gnu.org
2012-04-13 19:53 ` 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).