[PATCH 1/2] [gdb/build] Fix build with -std=c++11
Pedro Alves
pedro@palves.net
Mon Nov 15 14:05:30 GMT 2021
On 2021-11-15 13:55, Tom de Vries wrote:
> On 11/11/21 12:41 PM, Simon Marchi wrote:
>> It's not terribly important, but I was wondering whether this could be
>> fixed by adding the appropriate #ifdefs, to include or exclude the
>> problematic definitions. Providing our own declarations works too, but
>> with this there's always the risk that the signature is not exactly
>> right right, and we won't define exactly the right function.
>
> I also wondered about this, but AFAIU we cannot rely on a c++11
> implementation to provide some functionality if the user defines the
> feature macro. It's supposed to work the other way round: using the
> feature macro we detect whether something is supported.
>
> It would be nice if we could do something like:
> ...
> /* Tentatively define feature macro. */
> #define __cpp_sized_deallocation
> #include <new>
>
> #if still_not_defined
> extern void operator delete (void *p, std::size_t) noexcept;
> extern void operator delete[] (void *p, std::size_t) noexcept;
> #endif
> ...
> but I'm not sure how to formulate the still_not_defined test. Perhaps
> we could figure that out in a configure test, but I'm not sure that's
> worth the effort.
>
> Alternatively, we could do things unconditionally, like so:
> ...
> /* Tentatively define feature macro. */
> #define __cpp_sized_deallocation
> #include <new>
>
> extern void operator delete (void *p, std::size_t) noexcept;
> extern void operator delete[] (void *p, std::size_t) noexcept;
> ...
> to detect declaration mismatches.
I suspect the risk of defining a compiler/library feature macro (I'd guess this
is undefined behavior land) like __cpp_sized_deallocation behind the compiler's back and
that going wrong is higher than ending up with misdetected declaration mismatches.
More information about the Gdb-patches
mailing list