https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108407
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- With -fsanitize=undefined,address we get: ================================================================= ==1==ERROR: AddressSanitizer: stack-use-after-return on address 0x7ff991800030 at pc 0x0000004016c4 bp 0x7ffd675ea150 sp 0x7ffd675ea148 READ of size 4 at 0x7ff991800030 thread T0 #0 0x4016c3 in main /app/example.cpp:19 #1 0x7ff993d50082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee) #2 0x40115d in _start (/app/output.s+0x40115d) (BuildId: c6fef22ac59389c6ed0248b91200737f3dfa67d0) Address 0x7ff991800030 is located in stack of thread T0 at offset 48 in frame #0 0x401225 in create() /app/example.cpp:7 This frame has 2 object(s): [48, 52) 'a' (line 8) <== Memory access at offset 48 is inside this variable [64, 72) 'b' (line 9) HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork (longjmp and C++ exceptions *are* supported) SUMMARY: AddressSanitizer: stack-use-after-return /app/example.cpp:19 in main Shadow bytes around the buggy address: 0x7ff9917ffd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7ff9917ffe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7ff9917ffe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7ff9917fff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7ff9917fff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x7ff991800000: f5 f5 f5 f5 f5 f5[f5]f5 f5 f5 f5 f5 00 00 00 00 0x7ff991800080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7ff991800100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7ff991800180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7ff991800200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7ff991800280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==1==ABORTING