There some confusing/wrong error messages with the -std=c++0x option.
All three example statements below work fine without -std=c++0x and with
gcc versions <= 4.3. Seems to be a gcc bug and no C++0x demand (at least
the first 2 example statements).


typedef enum { AA=1, BB=2 } my_enum;

typedef struct { my_enum a:4 ; unsigned b:28; } stru;

void foo (char c, my_enum x, int i)
{
  char arr[2] = {c+'0', 0};
  stru s = {x,0};
  stru t = {i,0};
}


$ g++ -std=c++0x -c tst.c
tst.c: In function 'void foo(char, my_enum, int)':
tst.c:7: error: narrowing conversion of '(((int)c) + 48)' to 'char' inside { }
tst.c:8: error: narrowing conversion of 'x' to 'unsigned char:4' inside { }
tst.c:9: error: narrowing conversion of 'i' to 'unsigned char:4' inside { }


gcc trunk rev. 141404


-- 
           Summary: narrowing conversion with -std=c++0x
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: holger dot hopp at sap dot com
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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

Reply via email to