Hi all,

On 22.12.2017 18:29, Roman Lebedev wrote:

>> -- Performing Test DARKTABLE_HAVE_C_FLAG_WNO_FORMAT_TRUNCATION
>> -- Performing Test DARKTABLE_HAVE_C_FLAG_WNO_FORMAT_TRUNCATION - Success
>> -- Performing Test DARKTABLE_HAVE_CXX_FLAG_WNO_FORMAT_TRUNCATION
>> -- Performing Test DARKTABLE_HAVE_CXX_FLAG_WNO_FORMAT_TRUNCATION -
Success
>> ...
>> cc1: error: unrecognized command line option '-Wno-format-truncation'
>> [-Werror]
>> cc1: all warnings being treated as errors
> So it first says that the flag is supported, and then barfs at it. Touché.
>
> Given the date, i will revert the change that exposed this issue,
> but there is something *very* wrong going on here...



I just came to the same conclusion while trying to reproduce this on an
Ubuntu 16.04 install, which uses the exact same compiler version as
Linux Mint 18.3.

-Wformat-truncation doesn't seem to be a valid option for GCC 5.4.0
(it's not documented), but this version seems to silently accept the
negation under some circumstances (!):

sturmflut@hogsmeade:/tmp$ gcc -Wformat-truncation -o test test.c
gcc: error: unrecognized command line option ‘-Wformat-truncation’
sturmflut@hogsmeade:/tmp$ gcc -Wno-format-truncation -o test test.c
sturmflut@hogsmeade:/tmp$

(test.c just has an empty main() method).


So CHECK_COMPILER_FLAG_AND_ENABLE_IT(-Wno-format-truncation) in
./cmake/compiler-warnings.cmake is fooled into thinking this compiler
version actually supports -Wno-format-truncation at all times, because
the simple test case doesn't fail, but the compiler later decides to no
longer silently accept the invalid command line option for some reason.

Turns out one of the cases which trigger this is when the source file
under compilation has already generated some other warnings before. If I
do a make -j1 on a clean darktable checkout on this machine,
./src/iop/colortransfer.c actually is the first file which causes any
compiler warnings at all ("ISO C90 forbids variable length array"), so
this is why the process fails exactly there.



The minimum test case to trigger this behavior in GCC 5.4.0 is a C file
with a main() function with a parameter which has the wrong type, like
this one:


int main(int argc, int argv)
{
}



Then add -Wall to make sure the compiler will treat this as a warning,
and it fails:



sturmflut@hogsmeade:/tmp$ gcc -Wall -Wno-format-truncation -o test test.c
test.c:1:5: warning: second argument of ‘main’ should be ‘char **’ [-Wmain]
 int main(int argc, int argv)
     ^
cc1: warning: unrecognized command line option ‘-Wno-format-truncation’


If you omit -Wall, the compiler will not generate the first warning and
also not complain about -Wno-format-truncation.

I've never run into this before, but I guess Ubuntu 16.04 is going to
stay with us for a while since it is the current LTS release until may
2018, and even after that it will still be supported until 2021. So this
buggy GCC version will most likely also stay alive for quite a while.

kind regards,
Simon








___________________________________________________________________________
darktable developer mailing list
to unsubscribe send a mail to darktable-dev+unsubscr...@lists.darktable.org

Reply via email to