public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56155] New: [C++0X] enumeration with fixed underlying type - enum literals have wrong type
@ 2013-01-30 16:29 mib.bugzilla at gmail dot com
  2013-01-30 17:35 ` [Bug c++/56155] [C++0X] enumeration with fixed underlying type - enumerators have wrong type within enumerator-list redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: mib.bugzilla at gmail dot com @ 2013-01-30 16:29 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56155
           Summary: [C++0X] enumeration with fixed underlying type - enum
                    literals have wrong type
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mib.bugzilla@gmail.com


For an enumeration whose underlying type is fixed, the values of the
enumeration are the values of the underlying type. gcc appears to be ignoring
the underlying type, as the value of E_ in this example is 4

 gpp48 bug1.cpp -std=c++0x
bug1.cpp: In function âint main()â:
bug1.cpp:4:3: error: static assertion failed: E_ should be 1
   static_assert( E_ == 1, "E_ should be 1");
   ^

enum e_ : unsigned char { Z_, E_=sizeof(Z_) };
#include <stdio.h>
int main(void) {
  static_assert( E_ == 1, "E_ should be 1");
  printf("z is %d e is %d\n", Z_, E_ ); // prints 4
  printf("sizeof unsigned char is %d\n", sizeof(unsigned char)); // prints 1
  printf("sizeof e_ is %d\n", sizeof(e_)); // prints 1
  return 0;
}


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

* [Bug c++/56155] [C++0X] enumeration with fixed underlying type - enumerators have wrong type within enumerator-list
  2013-01-30 16:29 [Bug c++/56155] New: [C++0X] enumeration with fixed underlying type - enum literals have wrong type mib.bugzilla at gmail dot com
@ 2013-01-30 17:35 ` redi at gcc dot gnu.org
  2013-01-30 19:00 ` [Bug c++/56155] [C++11] " paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2013-01-30 17:35 UTC (permalink / raw)
  To: gcc-bugs


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-01-30
            Summary|[C++0X] enumeration with    |[C++0X] enumeration with
                   |fixed underlying type -     |fixed underlying type -
                   |enum literals have wrong    |enumerators have wrong type
                   |type                        |within enumerator-list
     Ever Confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-01-30 17:35:21 UTC ---
The type of the enumerator is only wrong within the enumerator-list, once the
enumeration declaration is complete sizeof(Z_) is 1 as expected.


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

* [Bug c++/56155] [C++11] enumeration with fixed underlying type - enumerators have wrong type within enumerator-list
  2013-01-30 16:29 [Bug c++/56155] New: [C++0X] enumeration with fixed underlying type - enum literals have wrong type mib.bugzilla at gmail dot com
  2013-01-30 17:35 ` [Bug c++/56155] [C++0X] enumeration with fixed underlying type - enumerators have wrong type within enumerator-list redi at gcc dot gnu.org
@ 2013-01-30 19:00 ` paolo.carlini at oracle dot com
  2013-01-30 19:16 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-01-30 19:00 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-01-30 19:00:29 UTC ---
Weird I thought we fixed this, we should find the relevant old PRs and see why
we are mishandling this specific case.


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

* [Bug c++/56155] [C++11] enumeration with fixed underlying type - enumerators have wrong type within enumerator-list
  2013-01-30 16:29 [Bug c++/56155] New: [C++0X] enumeration with fixed underlying type - enum literals have wrong type mib.bugzilla at gmail dot com
  2013-01-30 17:35 ` [Bug c++/56155] [C++0X] enumeration with fixed underlying type - enumerators have wrong type within enumerator-list redi at gcc dot gnu.org
  2013-01-30 19:00 ` [Bug c++/56155] [C++11] " paolo.carlini at oracle dot com
@ 2013-01-30 19:16 ` paolo.carlini at oracle dot com
  2013-02-13 17:56 ` jason at gcc dot gnu.org
  2013-02-15 19:27 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-01-30 19:16 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-01-30 19:16:12 UTC ---
I think I thought that Jason's work to completely fix c++/53524 had fixed this
too.


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

* [Bug c++/56155] [C++11] enumeration with fixed underlying type - enumerators have wrong type within enumerator-list
  2013-01-30 16:29 [Bug c++/56155] New: [C++0X] enumeration with fixed underlying type - enum literals have wrong type mib.bugzilla at gmail dot com
                   ` (2 preceding siblings ...)
  2013-01-30 19:16 ` paolo.carlini at oracle dot com
@ 2013-02-13 17:56 ` jason at gcc dot gnu.org
  2013-02-15 19:27 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2013-02-13 17:56 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2013-02-13 17:56:23 UTC ---
Author: jason
Date: Wed Feb 13 17:56:16 2013
New Revision: 196022

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196022
Log:
    PR c++/56155
    * decl.c (build_enumerator): Always convert the value to a
    fixed underlying type.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/enum22.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c


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

* [Bug c++/56155] [C++11] enumeration with fixed underlying type - enumerators have wrong type within enumerator-list
  2013-01-30 16:29 [Bug c++/56155] New: [C++0X] enumeration with fixed underlying type - enum literals have wrong type mib.bugzilla at gmail dot com
                   ` (3 preceding siblings ...)
  2013-02-13 17:56 ` jason at gcc dot gnu.org
@ 2013-02-15 19:27 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2013-02-15 19:27 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|                            |FIXED
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |
   Target Milestone|---                         |4.8.0

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2013-02-15 19:26:39 UTC ---
Fixed for 4.8.


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

end of thread, other threads:[~2013-02-15 19:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-30 16:29 [Bug c++/56155] New: [C++0X] enumeration with fixed underlying type - enum literals have wrong type mib.bugzilla at gmail dot com
2013-01-30 17:35 ` [Bug c++/56155] [C++0X] enumeration with fixed underlying type - enumerators have wrong type within enumerator-list redi at gcc dot gnu.org
2013-01-30 19:00 ` [Bug c++/56155] [C++11] " paolo.carlini at oracle dot com
2013-01-30 19:16 ` paolo.carlini at oracle dot com
2013-02-13 17:56 ` jason at gcc dot gnu.org
2013-02-15 19:27 ` 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).