mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: A little more progress today with clang/LLVM
Date: Sat, 26 May 2012 14:49:41 +0200	[thread overview]
Message-ID: <20120526124940.GI17860@port70.net> (raw)
In-Reply-To: <11654110.pFvND7RYFl@main.pennware.com>

* Richard Pennington <rich@pennware.com> [2012-05-26 06:39:25 -0500]:
> My tgmath.h test cases fail, for example (f is a float, d is a double):
> 

tgmath.h is non-trivial and is not extensively tested so there can be issues

> ../../../../../src/libs/math/001tgmath.c:15:7: error: assigning to 'float' from 
> incompatible type 'typeof (*(0
>       ? (typeof (0 ? (double *)0 : (void *)!!((1 ? 1 : ((f))) / 2)))0 : 
> (typeof (0 ? (typeof ((f)) *)0 :
>       (void *)!!!((1 ? 1 : ((f))) / 2)))0))' (aka 'void')

sounds like a clang bug

this code is marked with #ifdef __GNUC__ and
uses __typeof__ and ?: trics to be able to cast
the return value to the correct type


to try the messy expression above in isolation you can use:

#define T __typeof__
#define ISFP(x) !!((1?1:(x))/2)

float f = 0.1;
T(*(0 ? (T(0 ? (double *)0 : (void *)ISFP(f)))0 :
        (T(0 ? (T(f) *)0 : (void *)!ISFP(f)))0)) *x = &f;


but i think clang gets the ?: thing wrong
eg. try

__typeof__(0 ? (char*)0 : (void*)1) p;
void **pp = &p;

__typeof__(0 ? (char*)0 : (void*)0) q;
char **qq = &q;


(this should compile cleanly)


  reply	other threads:[~2012-05-26 12:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-22  1:47 Richard Pennington
2012-05-22  1:59 ` Rich Felker
2012-05-22  2:35   ` Richard Pennington
2012-05-22  2:53     ` Rich Felker
2012-05-22  3:24       ` Richard Pennington
2012-05-25 18:56   ` Richard Pennington
2012-05-25 23:09     ` Rich Felker
2012-05-26 11:30       ` Richard Pennington
2012-05-26 11:39         ` Richard Pennington
2012-05-26 12:49           ` Szabolcs Nagy [this message]
2012-05-26 11:59         ` Richard Pennington

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=20120526124940.GI17860@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).