It used to compile ok under GCC 3.x, but with GCC 4.2 there are false
positive warnings like
"warning: ‘b’ may be used uninitialized in this function".
I know why the compiler thinks so; from some point of view, the
compiler is right, and the code probably should not have been written
like that... but the code has worked for years, and it is much safer
and cheaper not to touch it rather than re-factor it.
(Also, I do not want to workaround it by erasing large structures at
run-time in a performance-critical routine, because it is just plain
wrong, it is wrong to suppress warnings by inserting unnecessary
code.)
So I want to disable this "may be uninitialized" warning in a single
file.
But for some reason,
#pragma GCC diagnostic ignored "-Wuninitialized"
has no effect: I have the same warnings treated as errors.
(yes, I am sure I have inserted it to the copy that I compile rather
than elsewhere)
The gcc is:
gcc (GCC) 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
> There is a big project, built for several target platforms, with
> warnings treated as errors.
>
> It used to compile ok under GCC 3.x, but with GCC 4.2 there are false
> positive warnings like
> "warning: ?b? may be used uninitialized in this function".
>
> I know why the compiler thinks so; from some point of view, the
> compiler is right, and the code probably should not have been written
> like that... but the code has worked for years, and it is much safer
> and cheaper not to touch it rather than re-factor it.
>
> (Also, I do not want to workaround it by erasing large structures at
> run-time in a performance-critical routine, because it is just plain
> wrong, it is wrong to suppress warnings by inserting unnecessary
> code.)
>
> So I want to disable this "may be uninitialized" warning in a single
> file.
>
> But for some reason,
> #pragma GCC diagnostic ignored "-Wuninitialized"
> has no effect: I have the same warnings treated as errors.
> (yes, I am sure I have inserted it to the copy that I compile rather
> than elsewhere)
>
> The gcc is:
> gcc (GCC) 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
Option '-Wno-uninitialized' turns it off.