[PATCH 04/40] cpu/cris: Initialize some variables on CRIS CPU

Hans-Peter Nilsson hp@bitrange.com
Sat Oct 22 01:59:57 GMT 2022


On Thu, 20 Oct 2022, Tsukasa OI via Binutils wrote:

> GCC / Clang generate a warning if a variable may be used uninitialized on
> some cases (Clang: "-Wsometimes-uninitialized").  When the program is being
> built by Clang with the default configuration, it causes a build failure
> (unless "--disable-werror" is specified).
> 
> Those error occur on sim/cris/semcrisv{10,32}f-switch.c but they are
> CGEN-generated files.  The real cause of this problem is in cpu/cris.cpu
> which does not initialize certain variables.

I'd say the problem is an artefact of CGEN code generation, as 
the conditions are exhaustive.  In the generated code it's far 
from obvious though...

> This commit ensures such variables are initialized to zero by default.
> Note that this commit itself does not regenerate CRIS CPU related files
> with CGEN because it still has several issues preventing regeneration.
> They are to be fixed in the later commits.
> 
> cpu/ChangeLog:
> 
> 	* cris.cpu: Initialize condres, newval and tmpres variables.

Ok with a comment saying something to the effect of "It's not 
obvious in generated code that all cases are covered in the 
conditional settings below, so initialize this to avoid compiler 
warnings" (and referring to the previous comment for all but the 
first).

Thanks!
brgds, H-P


More information about the Binutils mailing list