[Bug c/44543] New: moving static keyword causes compilation to fail

todd dot freed at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Jun 15 14:58:00 GMT 2010


Hello,

consider the following two declarations, which compile fine

static char f();
static char* f();

Then, if I move the 'static' keyword, like so:

char static f();
char* static f();

The first one still compiles, but the second one fails like this:

error.c:1: error: expected identifier or '(' before 'static'

I think this is a bug because if I use a non-pointer return type, like char or
int, it works fine. But if I use a pointer return type, like char* or void*, I
get the compiler error, depending on whether static is the first or second
word. Additionally, if I typedef char* charstar, and return that instead, it
works fine.

So, the file I am compiling is a one-liner, named error.c

char* static f();

using this command:

gcc error.c -c

Here's what I get from gcc -v

$ gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.3.3/configure --host=i686-pc-linux-gnu
--build=i686-pc-linux-gnu --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin
--sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share
--includedir=/usr/include --libdir=/usr/lib --localstatedir=/var
--libexecdir=/usr/lib --sharedstatedir=/usr/com --mandir=/usr/man
--infodir=/usr/info --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-c99 --enable-long-long --enable-clocale=gnu
--enable-languages=c,c++ --disable-libstdcxx-pch --program-suffix=-4.3.3
--disable-nls
Thread model: posix
gcc version 4.3.3 (GCC for Cross-LFS 4.3.3.20090323)


-- 
           Summary: moving static keyword causes compilation to fail
           Product: gcc
           Version: 4.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: todd dot freed at gmail dot com


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



More information about the Gcc-bugs mailing list