Friday 15 January 2010

static variables - gcc does not warn for unreachable code -


I wonder why GCC (4.6.3) is not accessible to me Code In this example:

  #include & lt; Stdio.h & gt; Integer position (zero) {constant integer first_time = 1; If (first_time) {return1; First_time = 0; / * Never reached * /} and {return 0; }} Ent Main (Int argate, Const four * AGR []) {printf ("First call% d \ n", status ()); Printf ("second call% d \ n", position ()); Return 0; }   

Note, the defective position () was the purpose of the function to maintain a position I used to warn with -wall I also tried to get me tried --Wearable-code , -extra , -pedantic and -ansi (As it was discussed). Nevertheless, none of them gives me a warning

It seems that the GCC removes static variable assignments silently.

In my opinion, the GCC option should be thrown an error to -wall-wester .

GCC 4.4 will warn you. This feature (wunakeb-code) has been removed in later versions of GCC.

Look here:

No comments:

Post a Comment