Issue 126440
Summary Failure to infer alignment of `malloc`
Labels missed-optimization
Assignees
Reporter Kmeakin
    According to cppreference, `malloc` should always return pointers that are at least as aligned as `max_align_t`. So the alignment test should always be true. gcc optimises this but LLVM does not:

https://godbolt.org/z/GnbEfbseE
https://alive2.llvm.org/ce/z/QZign2
```c
bool src(void) {
    void* p = malloc(1);
    return ((uintptr_t)p % alignof(max_align_t)) == 0;
}

bool tgt(void) { return true; }
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to