public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51675] New: [C++11][New in 4.7] Cannot create constexpr unions
@ 2011-12-24 18:25 classixretrox at gmail dot com
  2011-12-24 18:40 ` [Bug c++/51675] " classixretrox at gmail dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: classixretrox at gmail dot com @ 2011-12-24 18:25 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51675
           Summary: [C++11][New in 4.7] Cannot create constexpr unions
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: classixretrox@gmail.com


union foo
{
    int x = 0;
    short y;

    constexpr foo() = default;
};

This code compiles under GCC 4.6, however, not GCC 4.7.  It works if I remove
the constexpr keyword.

Output of GCC:
test.cc:6:12: error: explicitly defaulted function ‘constexpr foo::foo()’
cannot be declared as constexpr because the implicit declaration is not
constexpr:
test.cc:4:8: note: defaulted default constructor does not initialize ‘short int
foo::y’

If I provide only one initialization, it tells me that the others are
initialized.  If I initialize the others, it tells me that I can't initialize
more than one.  It essentially prevents the creation of constexpr unions.


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

end of thread, other threads:[~2012-02-08 10:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-24 18:25 [Bug c++/51675] New: [C++11][New in 4.7] Cannot create constexpr unions classixretrox at gmail dot com
2011-12-24 18:40 ` [Bug c++/51675] " classixretrox at gmail dot com
2011-12-24 22:26 ` [Bug c++/51675] [C++11][4.7 Regression] " paolo.carlini at oracle dot com
2012-01-02  5:41 ` jason at gcc dot gnu.org
2012-01-02 10:51 ` rguenth at gcc dot gnu.org
2012-01-02 17:54 ` jason at gcc dot gnu.org
2012-01-03 16:42 ` paolo.carlini at oracle dot com
2012-02-03  6:24 ` nephatrine at gmail dot com
2012-02-07  1:30 ` jason at gcc dot gnu.org
2012-02-08  9:53 ` jason at gcc dot gnu.org
2012-02-08 10:30 ` jakub 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).