LWN.net Logo

Hmm?

Hmm?

Posted Apr 8, 2011 7:45 UTC (Fri) by mpr22 (subscriber, #60784)
In reply to: Hmm? by khim
Parent article: LLVM 2.9 released

Haven't got a current GCC handy, but there are certainly extensions which you can't make -pedantic not complain about in 4.3.2 - case ranges being the one I just checked.


(Log in to post comments)

Are you sure?

Posted Apr 8, 2011 20:21 UTC (Fri) by khim (subscriber, #9252) [Link]

Hmm... Perhaps it's recent change, but with GCC 4.4 everything works fine:
$ cat test.c
#include <stdio.h>

int main(int argc, char **argv) {
  __extension__ (({
    switch (argc) {
      case 0 ... 5:
        printf("0 ... 5");
        break;
      default:
        printf("default");
        break;
    }
  }));
  return 0;
}
$ gcc --version
gcc-4.4 (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gcc -ansi -pedantic ./test.c -o test
$ ./test 1
0 ... 5
$ ./test 1 2 3 4 5 6
default

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds