mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: implicit conversion loses floating-point precision
Date: Mon, 7 Jul 2014 19:21:28 +0200	[thread overview]
Message-ID: <20140707172128.GB15705@port70.net> (raw)
In-Reply-To: <CAGj4m+5WwCM=aZgK-CaaKLGFB70pWHzMx7tbRtQ9C=t-6nZ44g@mail.gmail.com>

* Vasyl Vavrychuk <vvavrychuk@gmail.com> [2014-07-05 22:06:23 +0300]:
> I checked that gcc 4.8 outputs the same warning.

i could only reproduce it with clang

> On Sat, Jul 5, 2014 at 3:43 PM, Rich Felker <dalias@libc.org> wrote:
> > On Sat, Jul 05, 2014 at 02:25:02PM +0300, Vasyl Vavrychuk wrote:
> > > /usr/local/opt/musl/include/math.h:94:23: note: expanded from macro
> > > '__ISREL_DEF'
> > > { return !isunordered(__x,__y) && __x op __y; }
> > >           ~~~~~~~~~~~~^~~~~~~~
> > > /usr/local/opt/musl/include/math.h:90:34: note: expanded from macro
> > > 'isunordered'
> > > #define isunordered(x,y) (isnan((x)) ? ((void)(y),1) : isnan((y)))
> > >                                  ^
> > > /usr/local/opt/musl/include/math.h:67:45: note: expanded from macro
> > 'isnan'
> > >         sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) >
> > > 0x7f800000 : \
> >
> > This seems to be the problem: it's issuing warnings for the conversion
> > to float in the branch that only happens if x already has type float.
> > So this seems to be a bug in clang.
> >
> > I don't see any way around it without turning off the warning on
> > clang's side. From musl's side, working around it seems to require
> > non-portable, compiler-specific logic in the public headers which is
> > not something we want, especially when the issue it's addressing is
> > only a warning being issued due to compiler bugs. If you see a way to
> > work around it without doing this, let me know.

it can be worked around with explicit conversion

  sizeof(x) == sizeof(float) ? __FLOAT_BITS((float)x) ...

but this is ugly so clang should fix the warning

seems to be yet another c++ism in clang, implicit conversions
are more dangerous there because of function overloading

> > Also, normally compilers suppress any warnings from system headers or

that too


      reply	other threads:[~2014-07-07 17:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-05 11:25 Vasyl Vavrychuk
2014-07-05 12:43 ` Rich Felker
2014-07-05 19:06   ` Vasyl Vavrychuk
2014-07-07 17:21     ` Szabolcs Nagy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140707172128.GB15705@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).