Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 4 Apr 2014 17:00:11 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: Re: printf issues

On Fri, Apr 04, 2014 at 08:54:13PM +0200, Szabolcs Nagy wrote:
> > #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
> > long double modfl(long double x, long double *iptr)
> > {
> > return modf(x, (double *)iptr);
> > }
> 
> yes, this is an aliasing violation, nice catch
> 
> the original idea was to allow tail call opt for these wrappers,
> so they are a single branch instruction, we should fix it but
> i think we can rely on that the ptr representations are the same:
> 
> long double modfl(long double x, long double *iptr)
> {
> 	union {long double *ld; double *d;} u = {iptr};
> 	return modf(x, u.d);
> }

No, that doesn't change anything. The problem is that the object being
accessed is aliased with another type, which is illegal. The pointer
type/cast are not a problem, so this "workaround" is working around
the naive outward view of the issue ("bad pointer cast") and not the
actual issue (aliasing).

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.