NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: C++ language lawyer Q: requirements for bare abs()?



Andrew Cagney <andrew.cagney%gmail.com@localhost> writes:

> BTW, the "accepted answer"'s suggestion of using <stdlib.h> and abs()
> is just as broken as <math.h>.

Indeed, that seemed quite off!

>> In practice, it seems clear that the only reasonable coding approach is
>> to include <cmath> and then use std::abs() but the standards question
>> remains.
>
> Agreed.

Thanks.  Based on your comments, and everything else I've seen, I am
convinced that <cmath> and std::abs() is the only acceptable way to
write code, and that NetBSD is not wrong.

> How is "none" compiling?  Presumably #include <iostream> is up to no
> good, see appended.

Yes, I suspect iostream drags in other things, which seems buggy.

>> c++ -Wall cpp_abs.cpp; ./a.out
>>
>>                 none    math.h  cmath   both    both/R
>>  NetBSD/gcc7    1       1       1       1       1
>>  NetBSD/gcc10   1       1       1       1       1
>>  Debian/gcc12   1       1.5     1       1.5     1.5
>
> Alpine (musl) and Fedora with newer GCC's match this, see appended.

Thanks.  That's useful to know when running into people that think any
system not matching what the linux in front of them is wrong...

>>  macOS 10.13    DNC     DNC     1.5     1.5     1.5
>
> clang <= 18?  based on appended; also freebsd with clang

clang 10!

>>  macOS 13       1.5     1.5     1.5     1.5     1.5
>
> clang >18?  but could be a a header change

clang 14

macOS 15 has clang 17


Home | Main Index | Thread Index | Old Index