[cfe-dev] Why will clang never support all gnu99 extensions?
Dmitry Golovin via cfe-dev
cfe-dev at lists.llvm.org
Thu Jul 20 03:54:43 PDT 2017
Hi all!
I think this topic was discussed already, but I would like to bring it up one more time. First of all, I like clang and I don't want to insult anyone, I'm just asking about the developer's opinion on why some features are not supported.
Here is a test code for gnu99 standard compliance from elfutils:
int foo (int a)
{
for (int i = 0; i < a; ++i) if (i % 4) break; int s = a; return s;
}
double bar (double a, double b)
{
double square (double z) { return z * z; }
return square (a) + square (b);
}
void baz (int n)
{
struct S { int x[n]; };
}
Clang prints the following:
std99.c:8:28: error: function definition is not allowed here
double square (double z) { return z * z; }
^
std99.c:9:10: warning: implicit declaration of function 'square' is invalid in C99 [-Wimplicit-function-declaration]
return square (a) + square (b);
^
std99.c:14:18: error: fields must have a constant size: 'variable length array in structure' extension will never be supported
struct S { int x[n]; };
^
1 warning and 2 errors generated.
So the two missing features are the support for nested functions and VLA in struct. There is a bug regarding the first error (https://bugs.llvm.org/show_bug.cgi?id=9206) and it's a WONTFIX. The second error message looks like a lot of people asked to support the feature and also there is and explanation for it in Intentionally unsupported GCC extensions chapter of the documentation: "clang does not support the gcc extension that allows variable-length arrays in structures. This is for a few reasons: one, it is tricky to implement, two, the extension is completely undocumented, and three, the extension appears to be rarely used. Note that clang does support flexible array members (arrays with a zero or unspecified size at the end of a structure)." On the other hand there is another WONTFIX bug (https://bugs.llvm.org/show_bug.cgi?id=4071) that blocks building the Linux kernel. How serious are the developers about their position on intentionally unsupported extensions? What if someone implements support for these extensions and sends in a proper patch? Will it never be accepted?
Regards,
Dmitry
More information about the cfe-dev
mailing list