[cfe-dev] [libcxx/test] Puzzling floating point behaviour

Howard Hinnant hhinnant at apple.com
Sat Dec 10 12:39:08 PST 2011


On Dec 10, 2011, at 2:57 PM, Marc Glisse wrote:

> On Sat, 10 Dec 2011, Howard Hinnant wrote:
> 
>> In <math.h> you have:
>> 
>> double exp(double);
>> double sin(double);
>> double cos(double);
>> 
>> In <cmath> you *additionally* have:
>> 
>> namespace std
>> {
>> float exp(float);
>> double exp(double);
>> long double exp(long double);
>> 
>> float sin(float);
>> double sin(double);
>> long double sin(long double);
>> 
>> float cos(float);
>> double cos(double);
>> long double cos(long double);
>> }
> 
> We do agree that this is illegal, even in C++11, right?

No.

D.5  C standard library headers  [depr.c.headers]

1 ...

2 Every C header, each of which has a name of the form name.h, behaves as if each name placed in the standard library namespace by the corresponding cname header is placed within the global namespace scope. It is unspecified whether these names are first declared or defined within namespace scope (3.3.6) of the namespace std and are then injected into the global namespace scope by explicit using-declarations (7.3.3).

3 [ Example: The header <cstdlib> assuredly provides its declarations and definitions within the namespace std. It may also provide these names within the global namespace. The header <stdlib.h> assuredly provides the same declarations and definitions within the global namespace, much as in the C Standard. It may also provide these names within the namespace std. — end example ]

Howard





More information about the cfe-dev mailing list