#20 sdcc fails to notice extra comma in enum

closed
nobody
None
2
2004-11-13
2002-07-22
No

sdcc -mmcs51 --model-large --stack-after-data -c bug1a.c

struct x {
char a;
char b[10];
};

struct x test[3] =
{
{ 1, { 1, 2, 3, 4, 5, }, },
{ 2, { 1, }, },
{ 3, { 1, 2, 3, }, },
};

There are 7 spurious commas in the above which sdcc
doesn't complain about. Very perl but not very
standard C ;-) (I noticed this when compiling something
I'd written with sdcc with gcc).

Checked with today's sdcc from CVS

Discussion

  • Nick Craig-Wood

    Nick Craig-Wood - 2002-07-23

    Logged In: YES
    user_id=220462

    Bernhard Held pointed out on the mailing list that gcc &
    borland don't give a warning with this. I tried the ARM
    compiler and that doesn't either...

    I misremembered where the problem was when porting from gcc
    to sdcc -
    it was in enums not arrays...

    If you compile this with SDCC you don't get a warning

    enum x {
    A, B, C,
    };

    However if you compile with gcc you get

    gcc -Wall --pedantic -c bug1b.c
    bug1b.c:3: warning: comma at end of enumerator list

    Sorry for the confusing bug report!

     
  • Bernhard Held

    Bernhard Held - 2002-07-23
    • labels: 101552 -->
    • priority: 5 --> 2
    • summary: sdcc fails to notice extra comma inarray --> sdcc fails to notice extra comma in enum
     
  • Bernhard Held

    Bernhard Held - 2002-07-23

    Logged In: YES
    user_id=203539

    gcc will only emit a warning with --pedantic.
    IMO this is not a bug. I updated the subject and filed it as a
    feature request.

     
  • Borut Ražem

    Borut Ražem - 2004-11-13
    • status: open --> closed
     
  • Borut Ražem

    Borut Ražem - 2004-11-13

    Logged In: YES
    user_id=568035

    According to ISO C99, the trailing comma is allowed in enum
    declaration.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks