#1459: ExternalLibraries/PAPI does not build with gcc 4.8.1 ------------------------------------+--------------------------------------- Reporter: rhaas | Owner: Type: defect | Status: new Priority: major | Milestone: Component: EinsteinToolkit thorn | Version: development version Resolution: | Keywords: PAPI ------------------------------------+---------------------------------------
Comment (by rhaas):
It is a warning about shadowed variables and shadowing is in principle allowed in C so there needs not be an actual error. The only reason that the compilation aborts is that PAPI seems to use flags to turn warnings into errors (and presumably that gcc 4.8.1 contains more warnings in -Wall than 4.7 did). As far as I can tell there is no error. The code (schematically) looks like this: {{{ while(foo) { char * endptr; /* no use of endptr*/ if(bar) { char *endptr; strtod(...,&endptr); assert(*endptr == 0); } /* no use of endptr */ if(baz) { strtod(...,&endptr); assert(*endptr == 0); } /* no use of endptr */ } }}} so is correct code and contains no bug. I looked into it a bit more and more proposed solution is probably too radical. There are other warnings- turned-into-errors later on, in particular also one about const-casts in free()'s argument which I can never remove. Essentially what happens is that one has: {{{ struct blah { const char *uname; }; void somefunc(struct blah* b) { free((void*)b->uname); } }}} which triggers the warning since free takes a non-const argument (even though you cannot use the data pointed to by the pointer afterwards anyway).
Setting CFLAGS seems to just overwrite the CFLAGS that configure would use. Does anyone know how to append to the CFLAGS that configure constructs? Something like and --additional-cflags option?
I attach a patch to PAPI and its configure.sh that patches the affected source files (there are multiple other warnings that were turned into errors) during the configuration phase.
I am not sure if newer versions of PAPI compile successfully with gcc 4.8.1 or not.