Enabling clang Modules breaks type-generic math (tgmath.h)

Originator:nicolas.bouilleaud
Number:rdar://19217464 Date Originated:2014-12-11
Status:Open Resolved:
Product:Developer Tools Product Version:6.1
Classification:Serious Bug Reproducible:Always
 
When using clang modules, the macros defined in tgmath.h can’t be used in source code.

Steps to Reproduce:
Given this minimal sample:

```
#import <tgmath.h>
#import <Foundation/Foundation.h>
int main() { float f = round(0.42f); }
```
(Also attached as test.m)

The `round()` function is defined in math.h as returning a double, it’s overridden by the type-generic version in tgmath.h that returns a float. 

When compiling with `clang -Wconversion test.m`, there’s no conversion warning, which is the expected behaviour.

When compiling with `clang -fmodules -Wconversion test.m`, thus enabling modules, we have this warning:
```
test.m:3:24: warning: implicit conversion loses floating-point precision: 'double' to 'float' [-Wconversion]
int main() { float f = round(0.42f); }
                   ~   ^~~~~~~~~~~~
```
as if we didn’t import tgmath.h

Expected Results:
Using modules shouldn’t prevent importing tgmath.h

Actual Results:
tgmath.h macros are not usable.


Version:
Xcode 6.1, Mac OS X 10.10.1

Notes:
My best guess is that the math.h functions are builtin functions in clang, and somehow when using modules the builtin functions can’t be overridden.

Comments

This is a duplicate of http://www.openradar.me/16744288

By nicolas.bouilleaud at Dec. 11, 2014, 10:01 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!