Thoughts on -Winit-self
Joel Sherrill
joel.sherrill at oarcorp.com
Thu Sep 18 18:34:21 UTC 2014
Hi
I was provided a list of warning options for GCC to consider
for future inclusion. I have a local build with all of them added
and was looking to see if the warnings were appropriate and
valid for us. I would like to get community thoughts on
-Winit-self based on the case it flagged in JFFS2.
I reduced the code to this:
========================
#define uninitialized_var(x) x = x
int jffs2_block_check_erase(void *, void *jeb, unsigned int *bad_offset);
int jffs2_mark_erased_block(void *c, void *jeb)
{
unsigned int uninitialized_var(bad_offset);
return jffs2_block_check_erase(c, jeb, &bad_offset);
}
========================
sparc-rtems4.11-gcc -O2 -Wall -Winit-self -c warn.c
warn.c: In function 'jffs2_mark_erased_block':
warn.c:8:34: warning: 'bad_offset' is used uninitialized in this
function [-Wuninitialized]
unsigned int uninitialized_var(bad_offset);
Essentially this warning is tripped by the programming
idiom used to "inform" the compiler that this variable
is intentionally uninitialized.
The question for the community is:
+ Is this a case we would like to warn about?
+ Is this a programming idiom that is trusted enough that
we should never use this warning?
+ Is there a GCC attribute that we should use instead and
default to this when on a non-GCC compiler?
Basically, do we turn this on or not? If yes, then how to
fix the code warned about. If no, I would like some
rationale.
Thanks.
--
Joel Sherrill, Ph.D. Director of Research & Development
joel.sherrill at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the devel
mailing list