Created
May 4, 2018 09:52
-
-
Save catwell/2f0b644fd81ceca124632126380f349b to your computer and use it in GitHub Desktop.
Do not rely on compiler warnings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int foo(void) { | |
return 1; | |
} | |
int buggy(void) | |
{ | |
int len; | |
/* GCC with -Wall -Wextra will not warn. | |
* If you replace `while` by `if` it does. */ | |
while (foo() > 0) ++len; | |
return len; | |
} | |
int main() | |
{ | |
printf("%d\n", buggy()); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment