[clang] [Clang] Fix crash on invalid pointer argument to `__builtin_assume_aligned` (PR #233112)
Chen Miao via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 18 02:35:22 PDT 2026
================
@@ -102,3 +102,54 @@ void foo() {
f<int>(0); // expected-note {{in instantiation of function template specialization 'GH26612::f<int>' requested here}}
}
} // namespace GH26612
+
+namespace GH194289 {
+template<int qux>
+void bar() { // expected-note {{'bar' declared here}} expected-note {{possible target for call}}
+ int foo = (int *) __builtin_assume_aligned(baz, qux + 1);
+ // expected-error at -1 {{use of undeclared identifier 'baz'; did you mean 'bar'?}}
+ // expected-error at -2 {{reference to overloaded function could not be resolved}}
+ // expected-error at -3 {{cannot initialize a variable of type 'int'}}
----------------
ChenMiaoi wrote:
`int foo = (int *) __builtin_assume_aligned(baz, qux + 1);` introduces an unrelated initialization error. I think the example below is sufficient:
``` cc
template <int qux>
void bar() {
(void)__builtin_assume_aligned(baz, qux + 1);
}
```
https://github.com/llvm/llvm-project/pull/233112
More information about the cfe-commits
mailing list