gcc quirk not implemented

hi

gcc accepts this code:

int
__xuname(int namesize, void *namebuf)
{
        struct xutsname {
                char sysname[namesize]; /* Name of this OS. */
        } *name;
}

which clang refuses with:

const.c:5:25: error: arrays with static storage duration must have constant integer length
                char sysname[namesize]; /* Name of this OS. */
                            ^~~~~~~

note that this violates C99 but obviously it's used (for example in freebsd libc code)
so I believe it should get implemented.

roman

Thanks for the report; please file in Bugzilla so it doesn't get lost.
Looks like a serious pain to implement (structs with multiple
variable-sized members, anyone?), but I guess that's gcc compat.

-Eli

Yeah, GCC allows stuff after VLAs as well in structs (which is exposing an Ada feature through to C). I personally have no interest in implementing this sort of thing in Clang, but if someone else wanted to work on it, I wouldn't object :slight_smile:

-Chris

http://llvm.org/bugs/show_bug.cgi?id=2930