| Issue |
64707
|
| Summary |
gcc and llvm operations about operator new inconsistent
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
LukeSTM
|
clang: https://godbolt.org/z/E9Pj5W7d9
gcc: https://godbolt.org/z/v83bbPE99
```
#include <cstddef>
#include <new>
#include <iostream>
bool success=false;
struct alignas(2*__STDCPP_DEFAULT_NEW_ALIGNMENT__) A {
} a;
/*
Called by non-array new-expressions to allocate storage required for a single
object whose alignment requirement exceeds __STDCPP_DEFAULT_NEW_ALIGNMENT__
https://en.cppreference.com/w/cpp/memory/new/operator_new
*/
void* operator new(std::size_t, std::align_val_t) {
success=true;
return (void *) &a;
}
int test_it (void) {
A *a=new A();
return success;
}
int main()
{
test_it();
if (success == false) {
std::cout << "fail" << std::endl;
return 1;
}
std::cout << "success" <<std::endl;
return 0;
}
```
I see the asm
```
operator new(unsigned long, std::align_val_t): // @operator new(unsigned long, std::align_val_t)
adrp x8, success
adrp x0, a
add x0, x0, :lo12:a
mov w9, #1
strb w9, [x8, :lo12:success]
ret
test_it(): // @test_it()
adrp x8, success
ldrb w0, [x8, :lo12:success]
ret
```
checked the IR and asm, i think this error is cased by EarlyCSEPass. Becase after this pass ,there is no operator new in test_it().
Anyone have idea to fix it?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs