Skip to content

Instantly share code, notes, and snippets.

@catwell
Created May 4, 2018 09:52
Show Gist options
  • Save catwell/2f0b644fd81ceca124632126380f349b to your computer and use it in GitHub Desktop.
Save catwell/2f0b644fd81ceca124632126380f349b to your computer and use it in GitHub Desktop.
Do not rely on compiler warnings.
#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