[cfe-commits] r92987 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Driver/ToolChain.h lib/Driver/ToolChains.cpp lib/Driver/ToolChains.h lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGen/libcalls.c test/Driver/ana

Dan Gohman gohman at apple.com
Mon Jan 11 12:16:44 PST 2010


On Jan 10, 2010, at 2:07 PM, Nuno Lopes wrote:

>> On Jan 8, 2010, at 3:51 PM, Dan Gohman wrote:
>>>
>>> On Jan 8, 2010, at 2:15 PM, Nuno Lopes wrote:
>>>
>>>>> Author: djg
>>>>> Date: Thu Jan  7 20:20:44 2010
>>>>> New Revision: 92987
>>>>>
>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=92987&view=rev
>>>>> Log:
>>>>> Use -fno-math-errno by default, and remove the IsMathErrnoDefault
>>>>> targethook, which is no longer being used. This fixes PR5971.
>>>>
>>>> wow.. does this means that if I don't read the compiler's manual  
>>>> carefully and if I don't add -fmath-errno to the CFLAGS, my code   
>>>> will start to be silently miscompiled??
>>>> I don't think that giving up on correctness here is the right  
>>>> way  to go..
>>>
>>> This change isn't "giving up on correctness" (unless there are bugs
>>> with -fno-math-errno). Code that breaks was already not entirely
>>> portable in this regard.
>>>
>>> It may be "giving up on compatibility" though. Clang is a new
>>> compiler, and it's a good time to get things like this right, where
>>> feasible. However, I'll leave it up to the clang developers to
>>> decide what to do.
>>
>> We already have this behavior in llvm-gcc, so I think it is  
>> definitely the right thing for Clang.
>
> ok, reading the C99 standard 7.12.1p{2,4,5} it seems that you're  
> right. errno for math functions is implementation dependent. However  
> 'math_errhandling & MATH_ERRNO' must evaluate to 0 if it is not  
> defined.
> However, glibc at this point will evaluate that expression to 1 (http://sourceware.org/ml/glibc-cvs/2009-q3/msg00162.html 
> ). I guess now it's the libc's headers that need to be patched to  
> test for __clang__.

Offhand, I'd call that a library bug, in not providing a way for a  
compiler
to have -fno-math-errno get a corresponding math_errhandling value.
This is independent of which compiler is in use, and of whether
-fno-math-errno is the default.

But I won't object if the clang change must be reverted.

Dan




More information about the cfe-commits mailing list