[libcxx-dev] LLVM libcxx "hash" clashes with custom define "hash"

Oliver Major via libcxx-dev libcxx-dev at lists.llvm.org
Wed Jul 29 07:37:50 PDT 2020


Thanks a lot, that was exactly what I was looking for!

Best regards,
O. Major

Am Mi., 29. Juli 2020 um 15:13 Uhr schrieb Marshall Clow <
mclow.lists at gmail.com>:

> On Jul 29, 2020, at 5:32 AM, Oliver Major via libcxx-dev <
> libcxx-dev at lists.llvm.org> wrote:
>
>
> Hello everyone,
>
> I am new here and in fact not subscribed, I just have a question and don't
> even know if I am at the right address.
>
> We recently found a bug in our product code when building with NDK Clang
> for Android and it is related to the LLVM libcxx. It is fairly easy to
> reproduce and a quick internet search reveals that we are not the only ones
> with this or a similar issue.
>
> What we did, was
> #define hash #
>
> before
> #include <math.h>
>
> which let to a problem with libcxx/include/type_traits:417
> template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
>
> of course. We obviously shouldn't let defines leak into the stdlib, so it
> is our fault, we fixed it simply by renaming the define.
>
>
> Good.
>
>
> I didn't want to post it as a bug in the LLVM bugtracker, because I don't
> even think it needs fixing on LLVM side. I just wanted to make aware that
> this issue exists for some people and wanted to ask if there is a way to
> publicly document this issue somewhere, so people having problems with this
> can potentially find a solution on the internet.
>
>
> You’re not allowed to #define names that are defined in the standard
> library..
> See http://eel.is/c++draft/macro.names, which states:
>
> A translation unit that includes a standard library header shall
> not #define or #undef names declared in any standard library header.
>
> — Marshall
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-dev/attachments/20200729/c3aed49e/attachment.html>


More information about the libcxx-dev mailing list