Re: Need suggestion for using intypes.h features in centos5 gcc 4.1.2 compiler version.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 1, 2021 at 9:36 AM Jonathan Wakely via Gcc-help <
gcc-help@xxxxxxxxxxx> wrote:

> On Thu, 1 Apr 2021 at 15:47, Kannuswamy, Nanthakumar wrote:
> > Hope doing great. I mimic the production code here and would like to
> know the reason why gcc 8.2 is not throwing any warnings.
>
> Your code has undefined behaviour. The compiler cannot detect all
> forms of undefined behaviour at compile time.
>

This kind of problem can be detected at runtime though by using the address
sanitizer.
https://github.com/google/sanitizers/wiki/AddressSanitizerUseAfterReturn

rohan:2480$ g++ -fsanitize=address tmp.cc
rohan:2481$ ASAN_OPTIONS="detect_stack_use_after_return=1" ./a.out
String Return Name: ROUTEX_CI
Const Char Return Name with Instance Variable: ROUTEX_CI
=================================================================
==31164==ERROR: AddressSanitizer: stack-use-after-return on address
0x7fc3a5b00030 at pc 0x7fc3aa36366e bp 0x7ffff53d2700 sp 0x7ffff53d1ea8
READ of size 10 at 0x7fc3a5b00030 thread T0
...

Jim



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux