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

* [Bug c++/52915] [C++11] Deleted default-constructor of anonymous unions not honored
  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 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2012-04-12 22:07 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-04-12
                 CC|                            |jason at gcc dot gnu.org
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1


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

* [Bug c++/52915] [C++11] Deleted default-constructor of anonymous unions not honored
  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
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2012-04-13 19:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> 2012-04-13 19:43:43 UTC ---
Author: jason
Date: Fri Apr 13 19:43:37 2012
New Revision: 186432

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186432
Log:
    PR c++/52915
    * decl2.c (finish_anon_union): Use cp_finish_decl.
    * error.c (dump_function_name): Avoid showing anonymous "name".

Added:
    trunk/gcc/testsuite/g++.dg/other/anon-union2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl2.c
    trunk/gcc/cp/error.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/52915] [C++11] Deleted default-constructor of anonymous unions not honored
  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
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2012-04-13 19:53 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.8.0

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2012-04-13 19:53:28 UTC ---
Fixed for 4.8.


^ 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).