public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48537] New: C++0x: ICE using union with non-trivial member
@ 2011-04-10 3:17 yacwroy at gmail dot com
2011-04-18 17:44 ` [Bug c++/48537] " jason at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: yacwroy at gmail dot com @ 2011-04-10 3:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48537
Summary: C++0x: ICE using union with non-trivial member
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: yacwroy@gmail.com
Target: x86_64-unknown-linux-gnu
Created attachment 23936
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23936
Test source - ICEs.
If a union contains a member with a non-trivial default constructor, attempting
to explicitly call (or decltype) the default constructor results in an ICE.
(This relates to
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf, implemented
in GCC 4.6)
Simplest example (attached).
====== union-non-trivial-member-simple.cpp ========
struct SFoo
{
SFoo() =delete;
};
union UFoo
{
SFoo foo;
};
int main()
{
UFoo();
}
====================================================
> g++ union-non-trivial-member-simple.cpp -std=c++0x
====================================================
../union-non-trivial-member-simple.cpp: In function ‘int main()’:
../union-non-trivial-member-simple.cpp:13:8: internal compiler error: in
build_value_init_noctor, at cp/init.c:374
====================================================
NOTE: Line may not be 374 for you.
I've indicated the line here:
=========== cp/init.c ==============
build_value_init_noctor (tree type, tsubst_flags_t complain)
{
if (CLASS_TYPE_P (type))
{
gcc_assert (!TYPE_NEEDS_CONSTRUCTING (type)); // (<---- THIS LINE!!!!!!
if (TREE_CODE (type) != UNION_TYPE)
{
====================================
- Works as expected (error but no ICE) with copy constructor, assignment or
destructor.
- Works as expected (error but no ICE) for implicit declaration (eg: "UFoo
foo;").
- Can reject valid code if using SFINAE.
USEFULNESS:
I am attempting to use SFINAE (using decltype) on a template union containing a
given type to determine the trivial-ness of the given type's special member
functions.
[C++ standard:9.5.2]
"...[Note: If any non-static data member of a union has a non-trivial default
constructor (12.1 [class.ctor]), copy constructor (12.8 [class.copy]), copy
assignment operator (12.8 [class.copy]), or destructor (12.4 [class.dtor]), the
corresponding member function of the union must be user-declared or it will be
implicitly deleted (8.4 [dcl.fct.def]) for the union. —end note]"
Which (I hope) should allow classifications like "trivial class" to be
calculated without relying on compiler-specific stuff.
SPECS:
gcc: version 4.7.0 2011-04-05 (experimental) (svn = 171986)
gcc: version 4.6.0 2011-02-13 (experimental) (svn = 170074)
- tested with both.
- both GCCs manually patched by
(http://gcc.gnu.org/ml/gcc-patches/2007-04/msg00620.html)
- patch is unlikely to have any effect.
ubuntu: 10.10 (64 bit)
intel: core2 duo
HTH.
Simon.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/48537] C++0x: ICE using union with non-trivial member
2011-04-10 3:17 [Bug c++/48537] New: C++0x: ICE using union with non-trivial member yacwroy at gmail dot com
@ 2011-04-18 17:44 ` jason at gcc dot gnu.org
2011-04-18 22:41 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2011-04-18 17:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48537
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2011.04.18 17:44:00
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] 5+ messages in thread
* [Bug c++/48537] C++0x: ICE using union with non-trivial member
2011-04-10 3:17 [Bug c++/48537] New: C++0x: ICE using union with non-trivial member yacwroy at gmail dot com
2011-04-18 17:44 ` [Bug c++/48537] " jason at gcc dot gnu.org
@ 2011-04-18 22:41 ` jason at gcc dot gnu.org
2011-04-18 23:29 ` [Bug c++/48537] [4.6/4.7 regression] " jason at gcc dot gnu.org
2011-04-18 23:56 ` jason at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2011-04-18 22:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48537
--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> 2011-04-18 22:40:48 UTC ---
Author: jason
Date: Mon Apr 18 22:40:43 2011
New Revision: 172678
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172678
Log:
PR c++/48537
* init.c (build_value_init): Handle UNION_TYPE the same.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/union4.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/init.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/48537] [4.6/4.7 regression] C++0x: ICE using union with non-trivial member
2011-04-10 3:17 [Bug c++/48537] New: C++0x: ICE using union with non-trivial member yacwroy at gmail dot com
2011-04-18 17:44 ` [Bug c++/48537] " jason at gcc dot gnu.org
2011-04-18 22:41 ` jason at gcc dot gnu.org
@ 2011-04-18 23:29 ` jason at gcc dot gnu.org
2011-04-18 23:56 ` jason at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2011-04-18 23:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48537
--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-04-18 23:29:33 UTC ---
Author: jason
Date: Mon Apr 18 23:29:30 2011
New Revision: 172679
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172679
Log:
PR c++/48537
* init.c (build_value_init): Handle UNION_TYPE the same.
Added:
branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/union4.C
Modified:
branches/gcc-4_6-branch/gcc/cp/ChangeLog
branches/gcc-4_6-branch/gcc/cp/init.c
branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/48537] [4.6/4.7 regression] C++0x: ICE using union with non-trivial member
2011-04-10 3:17 [Bug c++/48537] New: C++0x: ICE using union with non-trivial member yacwroy at gmail dot com
` (2 preceding siblings ...)
2011-04-18 23:29 ` [Bug c++/48537] [4.6/4.7 regression] " jason at gcc dot gnu.org
@ 2011-04-18 23:56 ` jason at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2011-04-18 23:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48537
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.6.1
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-04-18 23:56:20 UTC ---
Fixed.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-04-18 23:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-10 3:17 [Bug c++/48537] New: C++0x: ICE using union with non-trivial member yacwroy at gmail dot com
2011-04-18 17:44 ` [Bug c++/48537] " jason at gcc dot gnu.org
2011-04-18 22:41 ` jason at gcc dot gnu.org
2011-04-18 23:29 ` [Bug c++/48537] [4.6/4.7 regression] " jason at gcc dot gnu.org
2011-04-18 23:56 ` 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).