[PATCH] assert: Support types without operator== (int) [BZ #21972]
Florian Weimer
fweimer@redhat.com
Fri Aug 18 17:41:00 GMT 2017
On 08/18/2017 07:30 PM, Paul Eggert wrote:
> Florian Weimer wrote:
>>> Florian Weimer wrote:
>>>> + ((void) sizeof (static_cast<bool> (expr)), __extension__ ({ \
>>> Can we instead replace 'sizeof ((expr) == 0)' with 'sizeof !(expr)'?
>>> That works in C, and if it also works in C++ it would avoid the need
>>> for the #ifdef __cplusplus.
>> It does not work in C++ because operator! could have been overloaded
>> or deleted.
>
> OK, then how about 'sizeof ((expr) ? 1 : 0)'? This should work because
> ?: cannot be overloaded.
Oh, this works. Updated patch attached.
Thanks,
Florian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: assert-c++.patch
Type: text/x-patch
Size: 5200 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20170818/723941a2/attachment.bin>
More information about the Libc-alpha
mailing list