checkedc / checkedc-llvm-project

This repo contains a version of clang that is modified to support Checked C. Checked C is an extension to C that lets programmers write C code with bounds checking and improved type-safety.
13 stars 19 forks source link

Fix for Issue #1200 "Assertion failure" #1201

Open arunkumarbhattar opened 1 year ago

arunkumarbhattar commented 1 year ago

Description: I encountered an assertion failure in the Clang compiler (Checked C branch) while compiling a Checked-C program. The assertion is triggered in the checkPointerTypesForAssignment function in SemaExpr.cpp, specifically at line 9155, where it checks if the RHSType is canonical.

Assertion `RHSType.isCanonical() && "RHS not canonicalized!"' failed.

The error message suggests submitting a bug report with the crash backtrace, preprocessed source, and associated run script. Here are the relevant details:

Crash backtrace: clang-12: /home/arun/Desktop/nonmacro/checkedc-llvm-project/clang/lib/Sema/SemaExpr.cpp:9155: clang::Sema::AssignConvertType checkPointerTypesForAssignment(clang::Sema&, clang::QualType, clang::QualType): Assertion `RHSType.isCanonical() && "RHS not canonicalized!"' failed.

Fix Description: added check for canonicalization as a last-ditch attempt to prevent assert error.

dtarditi commented 8 months ago

Could you supply a test case that reproduces this problem? I'm concerned that the fix, while it works, is not the right one. The function asserts that types are canonical as its first step. There is a problem where the types supplied by the calling function do not meeting this invariant?