public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/48780] New: [C++0x] scoped enumerations and va_arg (default argument promotions) @ 2011-04-26 20:56 hstong at ca dot ibm.com 2011-05-20 23:09 ` [Bug c++/48780] " jason at gcc dot gnu.org ` (6 more replies) 0 siblings, 7 replies; 8+ messages in thread From: hstong at ca dot ibm.com @ 2011-04-26 20:56 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48780 Summary: [C++0x] scoped enumerations and va_arg (default argument promotions) Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: hstong@ca.ibm.com CC: michaelw@ca.ibm.com Host: powerpc64-unknown-linux-gnu Target: powerpc64-unknown-linux-gnu In the 2011 FDIS, default argument promotions are defined to leave arguments of scoped enumeration types as-is (without conversion). This appears to be an interaction with old wording and I am not aware of any rationale behind this. For cases where the underlying type has rank lower than that of int, GCC performs the default argument promotions as-if the enumeration is unscoped. This manifests itself as a warning message and a run-time abend. In 5.2.2 [expr.call], If the argument has integral or enumeration type that is subject to the integral promotions (4.5), ..., the value of the argument is converted to the promoted type before the call. These promotions are referred to as the default argument promotions. In 4.5 [conv.prom], integral promotions are not specified to apply to scoped enumerations. ### Self-contained source (a.cpp): typedef __builtin_va_list __gnuc_va_list; typedef __gnuc_va_list va_list; enum struct A : short { X }; void foo(int x, ...) { va_list vl; __builtin_va_start(vl, x); enum A t = __builtin_va_arg(vl, enum A); __builtin_va_end(vl); } int main() { foo(0, A::X); } ### Compiler Invocation: g++ -std=c++0x -Wall -W -pedantic -c a.cpp ### Compiler Output (return code 0): /data/a.cpp: In function 'void foo(int, ...)': /data/a.cpp:9:11: warning: unused variable 't' [-Wunused-variable] /data/a.cpp:9:42: warning: 'A' is promoted to 'int' when passed through '...' [enabled by default] /data/a.cpp:9:42: note: (so you should pass 'int' not 'A' to 'va_arg') /data/a.cpp:9:42: note: if this code is reached, the program will abort ### Run output: Program received signal SIGTRAP, Trace/breakpoint trap. ### g++ -v output: Using built-in specs. Target: powerpc64-unknown-linux-gnu Configured with: ./configure --prefix=/data/gcc --program-suffix=-4.6.0 --disable-libssp --disable-libgcj --enable-version-specific-runtime-libs --with-cpu=default32 --enable-secureplt --with-long-double-128 --enable-shared --enable-__cxa_atexit --enable-threads=posix --enable-languages=c,c++,fortran --with-gmp=/usr/local Thread model: posix gcc version 4.6.0 (GCC) ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/48780] [C++0x] scoped enumerations and va_arg (default argument promotions) 2011-04-26 20:56 [Bug c++/48780] New: [C++0x] scoped enumerations and va_arg (default argument promotions) hstong at ca dot ibm.com @ 2011-05-20 23:09 ` jason at gcc dot gnu.org 2011-05-21 23:12 ` jason at gcc dot gnu.org ` (5 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: jason at gcc dot gnu.org @ 2011-05-20 23:09 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48780 Jason Merrill <jason at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2011.05.20 22:33:03 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] 8+ messages in thread
* [Bug c++/48780] [C++0x] scoped enumerations and va_arg (default argument promotions) 2011-04-26 20:56 [Bug c++/48780] New: [C++0x] scoped enumerations and va_arg (default argument promotions) hstong at ca dot ibm.com 2011-05-20 23:09 ` [Bug c++/48780] " jason at gcc dot gnu.org @ 2011-05-21 23:12 ` jason at gcc dot gnu.org 2011-05-22 1:06 ` jason at gcc dot gnu.org ` (4 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: jason at gcc dot gnu.org @ 2011-05-21 23:12 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48780 --- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-21 22:01:32 UTC --- Author: jason Date: Sat May 21 22:01:29 2011 New Revision: 174005 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174005 Log: PR c++/48780 * cvt.c (type_promotes_to): Don't promote scoped enums. Added: trunk/gcc/testsuite/g++.dg/cpp0x/enum12.C trunk/gcc/testsuite/g++.dg/cpp0x/enum13.C Modified: trunk/gcc/common.opt trunk/gcc/cp/ChangeLog trunk/gcc/cp/cvt.c trunk/gcc/doc/invoke.texi trunk/gcc/testsuite/ChangeLog ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/48780] [C++0x] scoped enumerations and va_arg (default argument promotions) 2011-04-26 20:56 [Bug c++/48780] New: [C++0x] scoped enumerations and va_arg (default argument promotions) hstong at ca dot ibm.com 2011-05-20 23:09 ` [Bug c++/48780] " jason at gcc dot gnu.org 2011-05-21 23:12 ` jason at gcc dot gnu.org @ 2011-05-22 1:06 ` jason at gcc dot gnu.org 2011-05-25 1:53 ` jason at gcc dot gnu.org ` (3 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: jason at gcc dot gnu.org @ 2011-05-22 1:06 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48780 --- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-22 00:28:47 UTC --- Author: jason Date: Sun May 22 00:28:44 2011 New Revision: 174022 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174022 Log: PR c++/48780 * cvt.c (type_promotes_to): Warn about promoting scoped enums. Added: branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/enum13.C Modified: branches/gcc-4_6-branch/gcc/cp/ChangeLog branches/gcc-4_6-branch/gcc/cp/cvt.c branches/gcc-4_6-branch/gcc/testsuite/ChangeLog ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/48780] [C++0x] scoped enumerations and va_arg (default argument promotions) 2011-04-26 20:56 [Bug c++/48780] New: [C++0x] scoped enumerations and va_arg (default argument promotions) hstong at ca dot ibm.com ` (2 preceding siblings ...) 2011-05-22 1:06 ` jason at gcc dot gnu.org @ 2011-05-25 1:53 ` jason at gcc dot gnu.org 2011-05-25 1:54 ` jason at gcc dot gnu.org ` (2 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: jason at gcc dot gnu.org @ 2011-05-25 1:53 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48780 Jason Merrill <jason at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED --- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-25 01:23:01 UTC --- . ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/48780] [C++0x] scoped enumerations and va_arg (default argument promotions) 2011-04-26 20:56 [Bug c++/48780] New: [C++0x] scoped enumerations and va_arg (default argument promotions) hstong at ca dot ibm.com ` (3 preceding siblings ...) 2011-05-25 1:53 ` jason at gcc dot gnu.org @ 2011-05-25 1:54 ` jason at gcc dot gnu.org 2011-06-07 15:10 ` jason at gcc dot gnu.org 2011-06-07 15:13 ` jason at gcc dot gnu.org 6 siblings, 0 replies; 8+ messages in thread From: jason at gcc dot gnu.org @ 2011-05-25 1:54 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48780 Jason Merrill <jason at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |4.7.0 --- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-25 01:19:26 UTC --- Fixed for 4.7.0. -Wabi warning added for 4.6.1. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/48780] [C++0x] scoped enumerations and va_arg (default argument promotions) 2011-04-26 20:56 [Bug c++/48780] New: [C++0x] scoped enumerations and va_arg (default argument promotions) hstong at ca dot ibm.com ` (4 preceding siblings ...) 2011-05-25 1:54 ` jason at gcc dot gnu.org @ 2011-06-07 15:10 ` jason at gcc dot gnu.org 2011-06-07 15:13 ` jason at gcc dot gnu.org 6 siblings, 0 replies; 8+ messages in thread From: jason at gcc dot gnu.org @ 2011-06-07 15:10 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48780 --- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-07 15:09:34 UTC --- Author: jason Date: Tue Jun 7 15:09:29 2011 New Revision: 174751 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174751 Log: PR c++/48780 * typeck.c (perform_integral_promotions): Don't promote scoped enums. * call.c (convert_arg_to_ellipsis): Promote them here in old ABI. Added: trunk/gcc/testsuite/g++.dg/cpp0x/enum19.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c trunk/gcc/cp/cvt.c trunk/gcc/cp/typeck.c trunk/gcc/testsuite/ChangeLog ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/48780] [C++0x] scoped enumerations and va_arg (default argument promotions) 2011-04-26 20:56 [Bug c++/48780] New: [C++0x] scoped enumerations and va_arg (default argument promotions) hstong at ca dot ibm.com ` (5 preceding siblings ...) 2011-06-07 15:10 ` jason at gcc dot gnu.org @ 2011-06-07 15:13 ` jason at gcc dot gnu.org 6 siblings, 0 replies; 8+ messages in thread From: jason at gcc dot gnu.org @ 2011-06-07 15:13 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48780 --- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-07 15:12:18 UTC --- Author: jason Date: Tue Jun 7 15:12:15 2011 New Revision: 174753 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174753 Log: PR c++/48780 * typeck.c (perform_integral_promotions): Don't promote scoped enums. * call.c (convert_arg_to_ellipsis): Promote them here in old ABI. Added: branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/enum19.C Modified: branches/gcc-4_6-branch/gcc/cp/ChangeLog branches/gcc-4_6-branch/gcc/cp/call.c branches/gcc-4_6-branch/gcc/cp/typeck.c branches/gcc-4_6-branch/gcc/testsuite/ChangeLog ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-06-07 15:13 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-04-26 20:56 [Bug c++/48780] New: [C++0x] scoped enumerations and va_arg (default argument promotions) hstong at ca dot ibm.com 2011-05-20 23:09 ` [Bug c++/48780] " jason at gcc dot gnu.org 2011-05-21 23:12 ` jason at gcc dot gnu.org 2011-05-22 1:06 ` jason at gcc dot gnu.org 2011-05-25 1:53 ` jason at gcc dot gnu.org 2011-05-25 1:54 ` jason at gcc dot gnu.org 2011-06-07 15:10 ` jason at gcc dot gnu.org 2011-06-07 15:13 ` 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).