Ricardo Signes <[email protected]> wrote:
> * [email protected] [2015-06-15T02:18:14]
>> v5.22.0-125-g4b95171 Configuration (common) -Acc=gcc-4.8 -Accflags="-O2 -W
>> -Wformat=2 -Wswitch -Wshadow -Wwrite-strings -Wuninitialized -Wall -pipe
>> -fomit-frame-pointer -D_FORTIFY_SOURCE=2 -Wpointer-arith -Wstrict-prototypes
>> -fstack-protector -Wstack-protector -Wextra -Wbad-function-cast -Wcast-align
>> -Wdisabled-optimization -Wendif-labels -Wfloat-equal -Wformat-nonliteral
>> -Winline -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wundef
>> -Wformat-security -march=native -pedantic"
>
> My understanding is that we know we don't build under pedantic, but that we
> were able to at most about one year ago, at f049db42e.
>
> * When did this stop?
> * Do we want to get back to building under pedantic?
> (Historically, it looks like something that was sorta-kinda desired, but not
> enough to make a big push.)
I'm afraid I can't directly answer those questions, but I have looked
into where the problems lie. As far as I can tell, the only thing that
fails under -pedantic is Encode. Specifically, Encode's enc2xs program
generates files like cpan/Encode/Byte/byte_t.c that look roughly like
this (massively cut down here):
static const encpage_t utf8_AdobeStandardEncoding[];
static const encpage_t utf8_AdobeStandardEncoding_c4[2] = {
{enctable + 3856,utf8_AdobeStandardEncoding,0xb1,0xb1,1,1},
{0,utf8_AdobeStandardEncoding_c4,0xb2,0xff,0,0},
};
static const encpage_t utf8_AdobeStandardEncoding[10] = { /* elided */ };
That is, the generated code has variables whose initialisations refer
to each other. In this case, the "utf8_AdobeStandardEncoding_c4"
variable (note trailing "_c4") has an initialisation that refers to
"utf8_AdobeStandardEncoding" (with no trailing bit). The first
declaration tries to declare a static array with no size or
initializer (the empty square brackets) as a forward declaration to be
used by the "c4" declaration. GCC apparently rejects this under
-pedantic:
byte_t.c:9:24: error: array size missing in 'utf8_AdobeStandardEncoding'
static const encpage_t utf8_AdobeStandardEncoding[];
^
byte_t.c:9:24: warning: uninitialized const
'utf8_AdobeStandardEncoding' is invalid in C++ [-Wc++-compat]
byte_t.c:867:24: error: conflicting types for 'utf8_AdobeStandardEncoding'
static const encpage_t utf8_AdobeStandardEncoding[10] = {
byte_t.c:9:24: note: previous declaration of
'utf8_AdobeStandardEncoding' was here
static const encpage_t utf8_AdobeStandardEncoding[];
I don't know whether GCC is correct here. If we assume it is, and we
want to be able to build under -pedantic (and under other compilers
that enforce the same restriction), then I think the solution would be
for enc2xs to topologically sort the graph of variables before
emitting them, rather than relying on these forward declarations.
--
Aaron Crane ** http://aaroncrane.co.uk/