Fixes PR45813
Details
Diff Detail
Event Timeline
Sorry, I don't understand the issue and can't write a better description.
Since this test triggers an assert in getCommonPtr that it "Cannot retrieve a NULL type pointer" of Ty->getPointeeType(), the fix just checks that the pointee is not null before using isVolatileQualified.
clang/lib/CodeGen/CodeGenFunction.cpp | ||
---|---|---|
2524 | Is the pointee type associated with a PointerType QualType ever supposed to be null? I wonder why this happens, and whether it can cause problems in other places. |
clang/lib/CodeGen/CodeGenFunction.cpp | ||
---|---|---|
2524 | Basically, we can't just use getPointeeType() here, but i'm not sure what should be used instead. |
clang/lib/CodeGen/CodeGenFunction.cpp | ||
---|---|---|
2524 | I'm not super familiar with __builtin_assume_aligned but from the GCC docs, it looks like the code from the test case is valid code (so we don't need to add semantic checking that would ensure we don't reach this code path). However, it seems a bit odd to me that we'd get an array type here as opposed to a decayed type which would actually be a pointer. I think the issue is further up the call chain, perhaps. EmitBuiltinExpr() gets the argument expression and passes it to emitAlignmentAssumption() which pulls the type directly out of the expression. It seems like there's an lvalue to rvalue conversion step missing to adjust the type. |
@orivej please can you look where we create AST nodes for these builtins and ensure that the "pointer" argument is actually converted into a pointer beforehand?
I'm afraid i can't readily point at the examples, but it should be easy-ish..
clang/lib/CodeGen/CodeGenFunction.cpp | ||
---|---|---|
2524 | Aha, yes, that does sound like the underying problem. |
-fsanitize=alignment -c a.c -O[012] no longer crashes for the test. From the comment that the problem was up the call chain, I think we can close this revision now.
Is the pointee type associated with a PointerType QualType ever supposed to be null? I wonder why this happens, and whether it can cause problems in other places.