public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members
@ 2012-10-13 17:36 daniel.kruegler at googlemail dot com
  2012-10-13 20:54 ` [Bug c++/54922] " daniel.kruegler at googlemail dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-10-13 17:36 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 54922
           Summary: [C++11][DR 1359] constexpr constructors require
                    initialization of all union members
    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 20120930 (experimental) compiled with the flags

-Wall -pedantic -std=c++11

rejects the following code:

//----------------
lass nullable_int
{
  bool init_;
  union {
    unsigned char for_value_init;
    int value_;
  };
public:
  constexpr nullable_int() : init_(false), for_value_init() {}
};
//----------------

"main.cpp||In constructor 'constexpr nullable_int::nullable_int()':|
main.cpp|9|error: uninitialized member 'nullable_int::<anonymous>' in
'constexpr' constructor|"

This prevents a very reasonable use-case, namely the creation of a literal type
that contains an anonymous union member.


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
@ 2012-10-13 20:54 ` daniel.kruegler at googlemail dot com
  2012-10-20 23:05 ` paolo.carlini at oracle dot com
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-10-13 20:54 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-10-13 20:54:14 UTC ---
(In reply to comment #0)
Some copy'n-paste error occurred while attempting to format the code example.
The correct code under investigation was:

//----------------
class nullable_int
{
  bool init_;
  union {
    unsigned char for_value_init;
    int value_;
  };
public:
  constexpr nullable_int() : init_(false), for_value_init() {}
};
//----------------


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
  2012-10-13 20:54 ` [Bug c++/54922] " daniel.kruegler at googlemail dot com
@ 2012-10-20 23:05 ` paolo.carlini at oracle dot com
  2012-10-20 23:21 ` paolo.carlini at oracle dot com
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-20 23:05 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-10-20
             Blocks|                            |55004
     Ever Confirmed|0                           |1


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
  2012-10-13 20:54 ` [Bug c++/54922] " daniel.kruegler at googlemail dot com
  2012-10-20 23:05 ` paolo.carlini at oracle dot com
@ 2012-10-20 23:21 ` paolo.carlini at oracle dot com
  2012-10-20 23:31 ` paolo.carlini at oracle dot com
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-20 23:21 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-20 23:21:42 UTC ---
Related to PR54768.


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
                   ` (2 preceding siblings ...)
  2012-10-20 23:21 ` paolo.carlini at oracle dot com
@ 2012-10-20 23:31 ` paolo.carlini at oracle dot com
  2012-10-22 12:43 ` paolo.carlini at oracle dot com
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-20 23:31 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-20 23:31:41 UTC ---
Related to PR51675.


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
                   ` (3 preceding siblings ...)
  2012-10-20 23:31 ` paolo.carlini at oracle dot com
@ 2012-10-22 12:43 ` paolo.carlini at oracle dot com
  2012-10-23 23:43 ` paolo at gcc dot gnu.org
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-22 12:43 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com
   Target Milestone|---                         |4.8.0

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-22 12:42:32 UTC ---
On it.


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
                   ` (4 preceding siblings ...)
  2012-10-22 12:43 ` paolo.carlini at oracle dot com
@ 2012-10-23 23:43 ` paolo at gcc dot gnu.org
  2012-10-23 23:44 ` paolo.carlini at oracle dot com
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-10-23 23:43 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #5 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-10-23 23:43:25 UTC ---
Author: paolo
Date: Tue Oct 23 23:43:21 2012
New Revision: 192749

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192749
Log:
/cp
2012-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/54922
    * semantics.c (cx_check_missing_mem_inits): Handle anonymous union
    members.

/testsuite
2012-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/54922
    * g++.dg/cpp0x/constexpr-union4.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-union4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
                   ` (5 preceding siblings ...)
  2012-10-23 23:43 ` paolo at gcc dot gnu.org
@ 2012-10-23 23:44 ` paolo.carlini at oracle dot com
  2012-11-07 11:05 ` paolo.carlini at oracle dot com
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-23 23:44 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-23 23:44:27 UTC ---
Fixed for 4.8.0.


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
                   ` (6 preceding siblings ...)
  2012-10-23 23:44 ` paolo.carlini at oracle dot com
@ 2012-11-07 11:05 ` paolo.carlini at oracle dot com
  2012-11-07 11:16 ` paolo.carlini at oracle dot com
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-07 11:05 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |
         AssignedTo|paolo.carlini at oracle dot |unassigned at gcc dot
                   |com                         |gnu.org

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-07 11:05:20 UTC ---
Patch is reverted for now. The fix wasn't correct (or was incomplete), as
showed by the testcase:

class nullable_int
{
  bool init_;
  union {
    unsigned char for_value_init;
    int value_;
  };
public:
  constexpr nullable_int() : init_(false), for_value_init() {}
};

int main()
{
  nullable_int n;
}


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
                   ` (7 preceding siblings ...)
  2012-11-07 11:05 ` paolo.carlini at oracle dot com
@ 2012-11-07 11:16 ` paolo.carlini at oracle dot com
  2012-11-07 11:16 ` paolo at gcc dot gnu.org
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-07 11:16 UTC (permalink / raw)
  To: gcc-bugs


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

Bug 54922 depends on bug 55226, which changed state.

Bug 55226 Summary: [4.8 Regression] ICE regression in regard to anonymous unions and constexpr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55226

           What    |Old Value                   |New Value
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #9 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-07 11:16:37 UTC ---
*** Bug 55226 has been marked as a duplicate of this bug. ***


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
                   ` (8 preceding siblings ...)
  2012-11-07 11:16 ` paolo.carlini at oracle dot com
@ 2012-11-07 11:16 ` paolo at gcc dot gnu.org
  2013-02-06  9:34 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-11-07 11:16 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #8 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-11-07 11:15:50 UTC ---
Author: paolo
Date: Wed Nov  7 11:15:40 2012
New Revision: 193292

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193292
Log:
/cp
2012-11-07  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/55226
    Revert:
    2012-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/54922
    * semantics.c (cx_check_missing_mem_inits): Handle anonymous union
    members.

/testsuite
2012-11-07  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/55226
    Revert:
    2012-10-23  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/54922
    * g++.dg/cpp0x/constexpr-union4.C: New.

Removed:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-union4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
                   ` (9 preceding siblings ...)
  2012-11-07 11:16 ` paolo at gcc dot gnu.org
@ 2013-02-06  9:34 ` paolo.carlini at oracle dot com
  2013-02-15  1:28 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-02-06  9:34 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |t-gcc-bugzilla at snowelm
                   |                            |dot com

--- Comment #10 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-02-06 09:34:07 UTC ---
*** Bug 56215 has been marked as a duplicate of this bug. ***


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
                   ` (10 preceding siblings ...)
  2013-02-06  9:34 ` paolo.carlini at oracle dot com
@ 2013-02-15  1:28 ` jason at gcc dot gnu.org
  2013-02-15 11:23 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2013-02-15  1:28 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> 2013-02-15 01:27:52 UTC ---
Author: jason
Date: Fri Feb 15 01:27:47 2013
New Revision: 196070

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196070
Log:
    PR c++/54922
    * semantics.c (build_anon_member_initialization): New.
    (build_data_member_initialization): Use it.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-union4.C
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-union5.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
                   ` (11 preceding siblings ...)
  2013-02-15  1:28 ` jason at gcc dot gnu.org
@ 2013-02-15 11:23 ` paolo.carlini at oracle dot com
  2013-02-15 19:38 ` jason at gcc dot gnu.org
  2013-03-09 22:16 ` paolo.carlini at oracle dot com
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-02-15 11:23 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #12 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-02-15 11:23:21 UTC ---
Fixed.


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
                   ` (12 preceding siblings ...)
  2013-02-15 11:23 ` paolo.carlini at oracle dot com
@ 2013-02-15 19:38 ` jason at gcc dot gnu.org
  2013-03-09 22:16 ` paolo.carlini at oracle dot com
  14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2013-02-15 19:38 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thomasmckee5 at gmail dot
                   |                            |com

--- Comment #13 from Jason Merrill <jason at gcc dot gnu.org> 2013-02-15 19:37:57 UTC ---
*** Bug 54768 has been marked as a duplicate of this bug. ***


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

* [Bug c++/54922] [C++11][DR 1359] constexpr constructors require initialization of all union members
  2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
                   ` (13 preceding siblings ...)
  2013-02-15 19:38 ` jason at gcc dot gnu.org
@ 2013-03-09 22:16 ` paolo.carlini at oracle dot com
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-03-09 22:16 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msharov at users dot
                   |                            |sourceforge.net

--- Comment #14 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-03-09 22:15:47 UTC ---
*** Bug 56583 has been marked as a duplicate of this bug. ***


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

end of thread, other threads:[~2013-03-09 22:16 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-13 17:36 [Bug c++/54922] New: [C++11][DR 1359] constexpr constructors require initialization of all union members daniel.kruegler at googlemail dot com
2012-10-13 20:54 ` [Bug c++/54922] " daniel.kruegler at googlemail dot com
2012-10-20 23:05 ` paolo.carlini at oracle dot com
2012-10-20 23:21 ` paolo.carlini at oracle dot com
2012-10-20 23:31 ` paolo.carlini at oracle dot com
2012-10-22 12:43 ` paolo.carlini at oracle dot com
2012-10-23 23:43 ` paolo at gcc dot gnu.org
2012-10-23 23:44 ` paolo.carlini at oracle dot com
2012-11-07 11:05 ` paolo.carlini at oracle dot com
2012-11-07 11:16 ` paolo.carlini at oracle dot com
2012-11-07 11:16 ` paolo at gcc dot gnu.org
2013-02-06  9:34 ` paolo.carlini at oracle dot com
2013-02-15  1:28 ` jason at gcc dot gnu.org
2013-02-15 11:23 ` paolo.carlini at oracle dot com
2013-02-15 19:38 ` jason at gcc dot gnu.org
2013-03-09 22:16 ` paolo.carlini at oracle dot com

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