LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 46207 - tgmath.h broken when compiling C with clang-cl
Summary: tgmath.h broken when compiling C with clang-cl
Status: NEW
Alias: None
Product: Runtime Libraries
Classification: Unclassified
Component: libc (show other bugs)
Version: trunk
Hardware: PC Windows NT
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-04 12:56 PDT by Steve Wishnousky
Modified: 2020-06-05 07:43 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Wishnousky 2020-06-04 12:56:20 PDT
The Universal CRT does not have a conforming complex.h. The tgmath.h header in Clang (https://github.com/llvm/llvm-project/blob/4cf5743b7784b2c2bff8be82e1a5cc37f8c68a36/clang/lib/Headers/tgmath.h) assumes a conforming complex.h and therefore cannot be compiled by clang-cl when building as C.

Repro:

**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.7.0-pre.3.0
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************

C:\Users\stwish\source>set "PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\Llvm\bin;%PATH%"

C:\Users\stwish\source>type tgmath_repro.c
#include <tgmath.h>

int main()
{
    return 0;
}

C:\Users\stwish\source>clang-cl tgmath_repro.c -ferror-limit=1
In file included from tgmath_repro.c:1:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\Llvm\lib\clang\10.0.0\include\tgmath.h(72,50): error: passing
      '_Complex float' to parameter of incompatible type '_Fcomplex' (aka 'struct _C_float_complex')
    __tg_acos(float _Complex __x) {return cacosf(__x);}
                                                 ^~~
C:\Program Files (x86)\Windows Kits\10\include\10.0.19620.0\ucrt\complex.h(98,50): note: passing argument to parameter '_Z' here
_ACRTIMP _Fcomplex __cdecl cacosf(_In_ _Fcomplex _Z);
                                                 ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 errors generated.
Comment 1 Hans Wennborg 2020-06-05 05:48:23 PDT
I'm not sure what the best way forward is here.

If we make Clang's tgmath.h defer to the UCRT tgmath.h, that avoids the current compile error. But it doesn't help users who actually want to use the type-generic macros.

And if the UCRT tgmath.h later implements support for type-generic macros, it's not clear that it would work with Clang since the implementation might be closely tied to the compiler.


Is there anything blocking the UCRT's complex.h from changing to be more conforming? Wouldn't that be beneficial in itself, that is, it would be good for developers using complex.h?