Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcc -fsanitize=undefined inhibits -Wuninitialized #1045

Closed
jonnygrant opened this issue Jan 20, 2019 · 4 comments
Closed

gcc -fsanitize=undefined inhibits -Wuninitialized #1045

jonnygrant opened this issue Jan 20, 2019 · 4 comments

Comments

@jonnygrant
Copy link

The "undefined" sanitizer appears to nullify issues otherwise identified by -Wuninitialized
could that be documented somewhere

Example program below after the output. I'm using GCC 8.2.0

$ gcc -Wall -fsanitize=signed-integer-overflow,leak,undefined,address -o undef undef.c
jonny@asus:/code$ ./undef
undef.c:18:15: runtime error: load of value 136, which is not a valid value for type '_Bool'
jonny@asus:
/code$ gcc -Wall -fsanitize=signed-integer-overflow,leak,address -o undef undef.c
undef.c: In function ‘main’:
undef.c:18:15: warning: ‘a.unset.hello’ is used uninitialized in this function [-Wuninitialized]
if(a.unset.hello)
~~~~~~~^~~~~~

// gcc -Wall -fsanitize=signed-integer-overflow,leak,undefined,address -o undef undef.c
#include <stdbool.h>

struct b
{
bool hello;
};

struct t
{
struct b unset;
};

int main()
{
struct t a;

if(a.unset.hello)
{
    return 1;
}

return 0;

}

@jonnygrant jonnygrant changed the title g++ -fsanitize=undefined gcc -fsanitize=undefined inhibits -Wuninitialized Jan 20, 2019
@kcc
Copy link
Contributor

kcc commented Feb 11, 2019

Seems to be a gcc-specific bug, please use the GCC bug tracker for this.

With clang, there is no warning from -Wuninitialized either way :(
You may want to file a bug against the LLVM bug tracker to implement it :)

@jonnygrant
Copy link
Author

ok, i posted here with the test case
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89284

@kcc
Copy link
Contributor

kcc commented Feb 11, 2019

thanks!

@kcc kcc closed this as completed Feb 11, 2019
@jonnygrant
Copy link
Author

GCC team fixed it.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89284

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants