public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60184] New: g++ does not allow static members of named unions
@ 2014-02-13 19:39 d0sboots at gmail dot com
  2014-06-06 10:10 ` [Bug c++/60184] " paolo.carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: d0sboots at gmail dot com @ 2014-02-13 19:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60184
           Summary: g++ does not allow static members of named unions
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: d0sboots at gmail dot com

cat > test.cc <<EOF
union Test {
  static constexpr int kConstant = 10;
};
EOF
g++ --std=c++0x -c -o test.o test.cc

produces:
test.cc:2:36: error: 'Test::kConstant' may not be static because it is a member
of a union

However, this is correct according to my reading of the standard, as well as
the folks here:
http://stackoverflow.com/questions/15996333/does-c11-allow-non-anonymous-unions-to-contain-static-data-members
It is also allowed by clang.

9/5 : "A union is a class defined with the class-key union; it holds only one
data member at a time"

Section 9.4, in general, describes static members. It places no restrictions on
static members in union-type classes.

9.5/1: "In a union, at most one of the non-static data members can be active at
any time, that is, the value of at most one of the non-static data members can
be stored in a union at any time."
There is no reason to specifically call out "non-static data members" unless
static data members can exist.

9.5/5: "The member-specification of an anonymous union shall only define
non-static data members."
This only applies to anonymous unions. That this is specifically called out for
anonymous unions implies that it *is* allowed in general.

gcc -v:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object
--enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
>From gcc-bugs-return-443505-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Feb 13 21:15:50 2014
Return-Path: <gcc-bugs-return-443505-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 20154 invoked by alias); 13 Feb 2014 21:15:50 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 20100 invoked by uid 55); 13 Feb 2014 21:15:44 -0000
From: "tejohnson at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/43631] var-tracking inserts notes with non-NULL BLOCK_FOR_INSN in between basic blocks
Date: Thu, 13 Feb 2014 21:15:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: 4.5.0
X-Bugzilla-Keywords: wrong-debug
X-Bugzilla-Severity: normal
X-Bugzilla-Who: tejohnson at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: steven at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.9.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-43631-4-0x2hZjjTph@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-43631-4@http.gcc.gnu.org/bugzilla/>
References: <bug-43631-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-02/txt/msg01262.txt.bz2
Content-length: 1680

http://gcc.gnu.org/bugzilla/show_bug.cgi?idC631

--- Comment #26 from tejohnson at gcc dot gnu.org ---
Author: tejohnson
Date: Thu Feb 13 21:15:06 2014
New Revision: 207766

URL: http://gcc.gnu.org/viewcvs?rev 7766&root=gcc&view=rev
Log:
2014-02-13  Teresa Johnson  <tejohnson@google.com>

        For Google b/12971524, backport r197994 to fix PR60141.

        2013-04-16  Steven Bosscher  <steven@gcc.gnu.org>

    PR middle-end/43631
    * emit-rtl.c (make_note_raw): New function.
    (link_insn_into_chain): New static inline function.
    (add_insn): Use it.
    (add_insn_before, add_insn_after): Factor insn chain linking code...
    (add_insn_before_nobb, add_insn_after_nobb): ...here, new functions
    using link_insn_into_chain.
    (note_outside_basic_block_p): New helper function for emit_note_after
    and emit_note_before.
    (emit_note_after): Use nobb variant of add_insn_after if the note
    should not be contained in a basic block.
    (emit_note_before): Use nobb variant of add_insn_before if the note
    should not be contained in a basic block.
    (emit_note_copy): Use make_note_raw.
    (emit_note): Likewise.
    * bb-reorder.c (insert_section_boundary_note): Remove hack to set
    BLOCK_FOR_INSN to NULL manually for NOTE_INSN_SWITCH_TEXT_SECTIONS.
    * jump.c (cleanup_barriers): Use reorder_insns_nobb to avoid making
    the moved barrier the tail of the basic block it follows.
    * var-tracking.c (pass_variable_tracking): Add TODO_verify_flow.

Modified:
    branches/google/gcc-4_8/gcc/bb-reorder.c
    branches/google/gcc-4_8/gcc/emit-rtl.c
    branches/google/gcc-4_8/gcc/jump.c
    branches/google/gcc-4_8/gcc/var-tracking.c


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

* [Bug c++/60184] g++ does not allow static members of named unions
  2014-02-13 19:39 [Bug c++/60184] New: g++ does not allow static members of named unions d0sboots at gmail dot com
@ 2014-06-06 10:10 ` paolo.carlini at oracle dot com
  2014-06-06 16:02 ` paolo.carlini at oracle dot com
  2014-06-06 16:02 ` paolo at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-06-06 10:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60184

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2014-06-06
             Blocks|                            |55004
           Assignee|unassigned at gcc dot gnu.org      |paolo.carlini at oracle dot com
   Target Milestone|---                         |4.10.0
     Ever confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Seems easy to fix.


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

* [Bug c++/60184] g++ does not allow static members of named unions
  2014-02-13 19:39 [Bug c++/60184] New: g++ does not allow static members of named unions d0sboots at gmail dot com
  2014-06-06 10:10 ` [Bug c++/60184] " paolo.carlini at oracle dot com
@ 2014-06-06 16:02 ` paolo.carlini at oracle dot com
  2014-06-06 16:02 ` paolo at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-06-06 16:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60184

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

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed for 4.10.0.


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

* [Bug c++/60184] g++ does not allow static members of named unions
  2014-02-13 19:39 [Bug c++/60184] New: g++ does not allow static members of named unions d0sboots at gmail dot com
  2014-06-06 10:10 ` [Bug c++/60184] " paolo.carlini at oracle dot com
  2014-06-06 16:02 ` paolo.carlini at oracle dot com
@ 2014-06-06 16:02 ` paolo at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: paolo at gcc dot gnu.org @ 2014-06-06 16:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60184

--- Comment #2 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Fri Jun  6 16:01:37 2014
New Revision: 211318

URL: http://gcc.gnu.org/viewcvs?rev=211318&root=gcc&view=rev
Log:
/cp
2014-06-06  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/60184
    * class.c (check_field_decls): In C++11 mode do not reject
    static data members and reference-type members in unions.

/testsuite
2014-06-06  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/60184
    * g++.dg/cpp0x/constexpr-union6.C: New.
    * g++.dg/cpp0x/union6.C: Likewise.
    * g++.dg/init/ref14.C: Adjust.
    * g++.dg/init/union1.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-union6.C
    trunk/gcc/testsuite/g++.dg/cpp0x/union6.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/init/ref14.C
    trunk/gcc/testsuite/g++.dg/init/union1.C


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

end of thread, other threads:[~2014-06-06 16:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-13 19:39 [Bug c++/60184] New: g++ does not allow static members of named unions d0sboots at gmail dot com
2014-06-06 10:10 ` [Bug c++/60184] " paolo.carlini at oracle dot com
2014-06-06 16:02 ` paolo.carlini at oracle dot com
2014-06-06 16:02 ` paolo 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).