[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon May 12 04:29:18 PDT 2025


AaronBallman wrote:

> Hi @AaronBallman
> 
> I see that if I build clang with ASAN with this patch and run the testcase `clang/test/C/C99/n590.c` it crashes and I see this
> 
> ```
> AddressSanitizer:DEADLYSIGNAL
> =================================================================
> ==2063954==ERROR: AddressSanitizer: SEGV on unknown address 0xb5c8001f7e52 (pc 0x7fe2bd0e8baf bp 0x7fe2bd718370 sp 0x7fe2bd7181a0 T0)
> ==2063954==The signal is caused by a WRITE memory access.
>     #0 0x7fe2bd0e8baf in raise (/lib64/libpthread.so.0+0x12baf) (BuildId: 1962602ac5dc3011b6d697b38b05ddc244197114)
>     #1 0x5610e162f93e in SignalHandler(int, siginfo_t*, void*) /repo/llvm/build-all-bbisdk-asan/../lib/Support/Unix/Signals.inc
>     #2 0x7fe2bd0e8d0f  (/lib64/libpthread.so.0+0x12d0f) (BuildId: 1962602ac5dc3011b6d697b38b05ddc244197114)
>     #3 0x5610e888912a in AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation, bool) /repo/llvm/build-all-bbisdk-asan/../../clang/lib/Sema/SemaChecking.cpp:12638
>     #4 0x5610e888a70b in CheckCommaOperand /repo/llvm/build-all-bbisdk-asan/../../clang/lib/Sema/SemaChecking.cpp:11653:3
>     #5 0x5610e888a70b in AnalyzeImplicitConversions /repo/llvm/build-all-bbisdk-asan/../../clang/lib/Sema/SemaChecking.cpp:12510:7
>     #6 0x5610e888a70b in AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation, bool) /repo/llvm/build-all-bbisdk-asan/../../clang/lib/Sema/SemaChecking.cpp:12642:5
>     [...]
>     #730 0x5610e888a70b in CheckCommaOperand /repo/llvm/build-all-bbisdk-asan/../../clang/lib/Sema/SemaChecking.cpp:11653:3
>     #731 0x5610e888a70b in AnalyzeImplicitConversions /repo/llvm/build-all-bbisdk-asan/../../clang/lib/Sema/SemaChecking.cpp:12510:7
>     #732 0x5610e888a70b in AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation, bool) /repo/llvm/build-all-bbisdk-asan/../../clang/lib/Sema/SemaChecking.cpp:12642:5
> 
> AddressSanitizer can not provide additional info.
> SUMMARY: AddressSanitizer: SEGV (/lib64/libpthread.so.0+0x12baf) (BuildId: 1962602ac5dc3011b6d697b38b05ddc244197114) in raise
> ==2063954==ABORTING
> ```

I'm trying to reproduce the issue on Windows with MSVC + ASAN and I'm not getting any failures. The stack trace looks valid, but also implies that `E = E->IgnoreParenImpCasts();` is somehow resulting in an invalid pointer being passed to `AnalyzeImplicitConversions()` which is a surprise; I would expect `E->` to be an issue if there was an invalid pointer involved with the changes in this PR. I may need a bit of help on this one if I can't reproduce locally.

https://github.com/llvm/llvm-project/pull/138752


More information about the cfe-commits mailing list