r192570 - Fixed "ArgSize may be used uninitialised" error whencompiling with gcc.

David Blaikie dblaikie at gmail.com
Tue Oct 15 09:42:19 PDT 2013


On Mon, Oct 14, 2013 at 11:20 PM, Andy Gibbs <andyg1001 at hotmail.co.uk>wrote:

> On Monday, October 14, 2013 6:16 PM, David Blaikie wrote:
>
>  Generally I believe we would prefer to disable the warning
>> than needlessly initialize the variable (is this needless
>> initialization? I haven't looked at the rest of the code,
>> but I assume it is). That way dynamic tools (MSan, Valgrind,
>> etc) can properly diagnose when the algorithm has bugs that
>> fail to initialize this variable.
>>
>
> And on Monday, October 14, 2013 6:33 PM, Robert Lytton wrote:
>
>  Hi David,
>>
>> Just to confirm that the initialization was needless.
>> All enum types are covered in switch statement.
>> Each case assigns to the variable.
>>
>
> Yes, each case assigns to the variable (even the one with the
> llvm_unreachable), but gcc seems to be over-zealous with this
> warning and doesn't consider the switch statement to be fully
> covered.  I think it happens under some specific optimisation
> level, but I don't know the ins and outs of it, this is just
> the impression I've gathered over time.
>
> David, what would be the best best way to disable the warning
> here?  I take your point about using dynamic tools, but the
> code in its current state will not compile under release mode
> with -Werror on gcc.  I wouldn't want to do some sort of
> kluge in the order of a diagnostic pragma; would you be happy
> with an alternative kludge: a LLVM_WEAK_INITIALIZE(...) macro
> inside llvm/Compiler.h that expands to nothing unless using
> gcc?  I guess there are loads of places across the whole code
> where this might be used; I don't think this is an isolated
> case of a technically unnecessary initialisation.


You're right, this isn't isolated - the solution is to literally disable
the warning for the whole project from within our build files. I believe we
already have some GCC diagnostics disabled, this would just be another to
add to that list.

Chandler (or many other people) might know more about the build system and
where this is best handled than I would, my naive guess would be (for the
Makefile build, at least - cc'ng Eric as the owner of that) in the "Options
To Invoke Tools" section of Makefile.rules, simply CompileCommonOpts +=
-Wno-maybe-uninitialized. Clang should have a no-op alias for this warning
(I haven't checked if it does) and supports more accurate warnings like
-Wsometimes-uninitialized (which should already be on in our builds) anyway.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131015/0a397e47/attachment.html>


More information about the cfe-commits mailing list