[Bug sanitizer/81040] asan false negative if parameter of a global function passed by reference

ryabinin.a.a at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Jun 13 09:47:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81040

--- Comment #7 from Andrey Ryabinin <ryabinin.a.a at gmail dot com> ---
(In reply to Martin Liška from comment #6)
> Can't see that clang++ is capable of catching your first test-case:
> 
> $ clang++ pr81040.cpp -fsanitize=address && ./a.out 
> pr81040.cpp:3:9: warning: expression result unused; assign into a variable
> to force a volatile load [-Wunused-volatile-lvalue]
>         *(volatile int*)a;
>         ^~~~~~~~~~~~~~~~~
> 1 warning generated.
> 

Try simply 'clang' without ++ 
Seems clang++ just optimize away unused volatile lvalue.

Or just make goo() to use *a, e.g.:
static __attribute__((noinline)) int goo(int *a)                                
{                                                                               
        return *(volatile int*)a;                                               
}


> $ clang++ --version
> clang version 4.0.0 (tags/RELEASE_400/final 297347)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
> InstalledDir: /usr/bin


More information about the Gcc-bugs mailing list