public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++
@ 2023-01-13  9:43 jincikang at gmail dot com
  2023-01-13 12:54 ` [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++ redi at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: jincikang at gmail dot com @ 2023-01-13  9:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391

            Bug ID: 108391
           Summary: Operator '::operator delete(void*, size_t)' was not
                    found when clang compiled stdlibc++
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jincikang at gmail dot com
  Target Milestone: ---

```C++
// main.cpp
#include <new>

int main() {
  void* p = ::operator new[](2);
  ::operator delete[](p, 2);
}
```

# no problem
$ g++ main.cpp -std=c++20
# no problem
$ clang++ main.cpp -std=c++20 -stdlib=libc++
$ clang++ main.cpp -std=c++20 
main.cpp:5:3: error: no matching function for call to 'operator delete[]'
  ::operator delete[](p, 2);
  ^~~~~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/new:146:6:
note: candidate function not viable: no known conversion from 'int' to 'const
std::nothrow_t' for 2nd argument
void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/new:161:6:
note: candidate function not viable: no known conversion from 'int' to
'std::align_val_t' for 2nd argument
void operator delete[](void*, std::align_val_t)
     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/new:181:13:
note: candidate function not viable: no known conversion from 'int' to 'void *'
for 2nd argument
inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { }
            ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/new:132:6:
note: candidate function not viable: requires 1 argument, but 2 were provided
void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT
     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/new:163:6:
note: candidate function not viable: requires 3 arguments, but 2 were provided
void operator delete[](void*, std::align_val_t, const std::nothrow_t&)
     ^
1 error generated


* The reason is that clang does not define the macro __cpp_sized_deallocation.
* I think `#ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION` in libc++ might
be a bit better

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++
  2023-01-13  9:43 [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ jincikang at gmail dot com
@ 2023-01-13 12:54 ` redi at gcc dot gnu.org
  2023-01-13 13:00 ` redi at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2023-01-13 12:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to jinci kang from comment #0)
> * The reason is that clang does not define the macro
> __cpp_sized_deallocation.

Well then that's a clang bug. It shouldn't be trying to use sized delete if it
hasn't informed the std::lib that sized delete is supported.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++
  2023-01-13  9:43 [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ jincikang at gmail dot com
  2023-01-13 12:54 ` [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++ redi at gcc dot gnu.org
@ 2023-01-13 13:00 ` redi at gcc dot gnu.org
  2023-01-13 13:08 ` jincikang at gmail dot com
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2023-01-13 13:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Oh clang isn't using it, you're using it explicitly. So then that's a bug in
your code. You shouldn't use it unless the macro is defined to say that it's
usable.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++
  2023-01-13  9:43 [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ jincikang at gmail dot com
  2023-01-13 12:54 ` [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++ redi at gcc dot gnu.org
  2023-01-13 13:00 ` redi at gcc dot gnu.org
@ 2023-01-13 13:08 ` jincikang at gmail dot com
  2023-01-13 13:14 ` jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jincikang at gmail dot com @ 2023-01-13 13:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391

--- Comment #3 from jinci kang <jincikang at gmail dot com> ---
(In reply to Jonathan Wakely from comment #2)
> Oh clang isn't using it, you're using it explicitly. So then that's a bug in
> your code. You shouldn't use it unless the macro is defined to say that it's
> usable.

So what do you think I should do?
```cpp
#ifdef __clang__
#define __cpp_sized_deallocation
#endif

#include <new>

int main() {
  void* p = ::operator new[](2);
  ::operator delete[](p, 2);
}
```
I think this is a bit troublesome, this API can be used directly after C++14.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++
  2023-01-13  9:43 [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ jincikang at gmail dot com
                   ` (2 preceding siblings ...)
  2023-01-13 13:08 ` jincikang at gmail dot com
@ 2023-01-13 13:14 ` jakub at gcc dot gnu.org
  2023-01-13 13:17 ` jincikang at gmail dot com
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-13 13:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
No, but:
#include <new>

int main() {
  void* p = ::operator new[](2);
#if __cpp_sized_deallocation >= 201309
  ::operator delete[](p, 2);
#else
  ::operator delete[](p);
#endif
}
or so.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++
  2023-01-13  9:43 [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ jincikang at gmail dot com
                   ` (3 preceding siblings ...)
  2023-01-13 13:14 ` jakub at gcc dot gnu.org
@ 2023-01-13 13:17 ` jincikang at gmail dot com
  2023-01-13 13:25 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jincikang at gmail dot com @ 2023-01-13 13:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391

--- Comment #5 from jinci kang <jincikang at gmail dot com> ---
(In reply to Jakub Jelinek from comment #4)
> No, but:
> #include <new>
> 
> int main() {
>   void* p = ::operator new[](2);
> #if __cpp_sized_deallocation >= 201309
>   ::operator delete[](p, 2);
> #else
>   ::operator delete[](p);
> #endif
> }
> or so.

Ok. I see. thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++
  2023-01-13  9:43 [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ jincikang at gmail dot com
                   ` (4 preceding siblings ...)
  2023-01-13 13:17 ` jincikang at gmail dot com
@ 2023-01-13 13:25 ` redi at gcc dot gnu.org
  2023-01-13 13:40 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2023-01-13 13:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |MOVED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to jinci kang from comment #3)
> So what do you think I should do?
> ```cpp
> #ifdef __clang__
> #define __cpp_sized_deallocation
> #endif

No, don't do that! That has undefined behaviour. 

> I think this is a bit troublesome, this API can be used directly after C++14.

Well like I said, it's a clang bug. The C++ standard requires the macro to be
defined, but if Clang doesn't do that, the library won't declare the
corresponding API.

You should report this to Clang, not here.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++
  2023-01-13  9:43 [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ jincikang at gmail dot com
                   ` (5 preceding siblings ...)
  2023-01-13 13:25 ` redi at gcc dot gnu.org
@ 2023-01-13 13:40 ` jakub at gcc dot gnu.org
  2023-01-13 13:46 ` jincikang at gmail dot com
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-13 13:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Grep shows that clang predefines that macro if -fsized-deallocation is used.
But why that option doesn't default to on for C++14 is hard to understand.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++
  2023-01-13  9:43 [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ jincikang at gmail dot com
                   ` (6 preceding siblings ...)
  2023-01-13 13:40 ` jakub at gcc dot gnu.org
@ 2023-01-13 13:46 ` jincikang at gmail dot com
  2023-01-13 13:50 ` jincikang at gmail dot com
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jincikang at gmail dot com @ 2023-01-13 13:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391

--- Comment #8 from jinci kang <jincikang at gmail dot com> ---
(In reply to Jakub Jelinek from comment #7)
> Grep shows that clang predefines that macro if -fsized-deallocation is used.
> But why that option doesn't default to on for C++14 is hard to understand.

Clang has a problem with ABI breaking.
https://reviews.llvm.org/D8467

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++
  2023-01-13  9:43 [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ jincikang at gmail dot com
                   ` (7 preceding siblings ...)
  2023-01-13 13:46 ` jincikang at gmail dot com
@ 2023-01-13 13:50 ` jincikang at gmail dot com
  2023-01-13 13:53 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jincikang at gmail dot com @ 2023-01-13 13:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391

--- Comment #9 from jinci kang <jincikang at gmail dot com> ---
This issue can be closed, but I don't know how to close this, can you help me
to close it.Thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++
  2023-01-13  9:43 [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ jincikang at gmail dot com
                   ` (8 preceding siblings ...)
  2023-01-13 13:50 ` jincikang at gmail dot com
@ 2023-01-13 13:53 ` redi at gcc dot gnu.org
  2023-01-13 13:54 ` jincikang at gmail dot com
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2023-01-13 13:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I've already closed it

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++
  2023-01-13  9:43 [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ jincikang at gmail dot com
                   ` (9 preceding siblings ...)
  2023-01-13 13:53 ` redi at gcc dot gnu.org
@ 2023-01-13 13:54 ` jincikang at gmail dot com
  2023-01-13 14:20 ` redi at gcc dot gnu.org
  2023-01-13 15:52 ` jincikang at gmail dot com
  12 siblings, 0 replies; 14+ messages in thread
From: jincikang at gmail dot com @ 2023-01-13 13:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391

--- Comment #11 from jinci kang <jincikang at gmail dot com> ---
OK

redi at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org> 于2023年1月13日周五 21:53写道:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391
>
> --- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> I've already closed it
>
> --
> You are receiving this mail because:
> You reported the bug.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++
  2023-01-13  9:43 [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ jincikang at gmail dot com
                   ` (10 preceding siblings ...)
  2023-01-13 13:54 ` jincikang at gmail dot com
@ 2023-01-13 14:20 ` redi at gcc dot gnu.org
  2023-01-13 15:52 ` jincikang at gmail dot com
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2023-01-13 14:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391

--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to jinci kang from comment #8)
> Clang has a problem with ABI breaking.
> https://reviews.llvm.org/D8467

Ah yes. The most recent attempt to fix it is at:
https://reviews.llvm.org/D112921

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++
  2023-01-13  9:43 [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ jincikang at gmail dot com
                   ` (11 preceding siblings ...)
  2023-01-13 14:20 ` redi at gcc dot gnu.org
@ 2023-01-13 15:52 ` jincikang at gmail dot com
  12 siblings, 0 replies; 14+ messages in thread
From: jincikang at gmail dot com @ 2023-01-13 15:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391

--- Comment #13 from jinci kang <jincikang at gmail dot com> ---
(In reply to Jonathan Wakely from comment #12)
> (In reply to jinci kang from comment #8)
> > Clang has a problem with ABI breaking.
> > https://reviews.llvm.org/D8467
> 
> Ah yes. The most recent attempt to fix it is at:
> https://reviews.llvm.org/D112921

OK, all right.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-01-13 15:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-13  9:43 [Bug libstdc++/108391] New: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ jincikang at gmail dot com
2023-01-13 12:54 ` [Bug libstdc++/108391] '::operator delete(void*, size_t)' was not found when clang compiled libstdc++ redi at gcc dot gnu.org
2023-01-13 13:00 ` redi at gcc dot gnu.org
2023-01-13 13:08 ` jincikang at gmail dot com
2023-01-13 13:14 ` jakub at gcc dot gnu.org
2023-01-13 13:17 ` jincikang at gmail dot com
2023-01-13 13:25 ` redi at gcc dot gnu.org
2023-01-13 13:40 ` jakub at gcc dot gnu.org
2023-01-13 13:46 ` jincikang at gmail dot com
2023-01-13 13:50 ` jincikang at gmail dot com
2023-01-13 13:53 ` redi at gcc dot gnu.org
2023-01-13 13:54 ` jincikang at gmail dot com
2023-01-13 14:20 ` redi at gcc dot gnu.org
2023-01-13 15:52 ` jincikang at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).