编译有警告
main.cpp:43:46: warning: object backing the pointer will be destroyed at the end of the full-expression [-Wdangling-gsl]
const ReducedGroupId& reduced_group_id = memo.GetReduceGroupId(group_id).value();
运行有 asan
==7760==ERROR: AddressSanitizer: stack-use-after-scope on address 0x00016ba93320 at pc 0x00010436df8c bp 0x00016ba93250 sp 0x00016ba93248
READ of size 8 at 0x00016ba93320 thread T0
#0 0x10436df88 in main+0x610 (a.out:arm64+0x100001f88)
#1 0x187dbe0dc (<unknown module>)
Address 0x00016ba93320 is located in stack of thread T0 at offset 192 in frame
#0 0x10436d984 in main+0xc (a.out:arm64+0x100001984)
This frame has 7 object(s):
[32, 40) 'ref.tmp.i.i124'
[64, 72) 'ref.tmp.i.i103'
[96, 104) 'ref.tmp.i.i'
[128, 152) 'tmp'
[192, 208) 'ref.tmp' <== Memory access at offset 192 is inside this variable
[224, 232) 'ref.tmp15'
[256, 264) 'ref.tmp28'
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-scope (a.out:arm64+0x100001f88) in main+0x610 |