Re: Suspicion of a compiler bug in clang: using ternary operator in ereport() - Mailing list pgsql-hackers

From Christian Kruse
Subject Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()
Date
Msg-id 20140130092505.GH3557@defunct.ch
Whole thread Raw
In response to Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

On 30/01/14 10:15, Andres Freund wrote:
> > While I understand most modifications I'm a little bit confused by
> > some parts. Have a look at for example this one:
> >
> > +       *errstr = psprintf(_("failed to look up effective user id %ld: %s"),
> > +                          (long) user_id,
> > +                        errno ? strerror(errno) : _("user does not exist"));
> >
> > Why is it safe here to use errno? It is possible that the _() function
> > changes errno, isn't it?
>
> But the evaluation order is strictly defined here, no? First the boolean
> check for errno, then *either* strerror(errno), *or* the _().

Have a look at the psprintf() call: we first have a _("failed to look
up effective user id %ld: %s") as an argument, then we have a (long)
user_id and after that we have a ternary expression using errno. Isn't
it possible that the first _() changes errno?

Best regards,

-- Christian Kruse               http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services


pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()
Next
From: Jeevan Chalke
Date:
Subject: Re: patch: option --if-exists for pg_dump