Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Christian Kruse <christian(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()
Date: 2014-01-30 09:15:21
Message-ID: 20140130091521.GM30218@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2014-01-30 08:32:20 +0100, Christian Kruse wrote:
> Hi Tom,
>
> On 29/01/14 20:06, Tom Lane wrote:
> > Christian Kruse <christian(at)2ndquadrant(dot)com> writes:
> > > Your reasoning sounds quite logical to me. Thus I did a
> > > grep -RA 3 "ereport" src/* | less
> > > and looked for ereport calls with errno in it. I found quite a few,
> > > attached you will find a patch addressing that issue.
> >
> > Committed.
>
> Great! Thanks!
>
> > I found a couple of errors in your patch, but I think everything is
> > addressed in the patch as committed.
>
> 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 _().

Greetings,

Andres Freund

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christian Kruse 2014-01-30 09:25:05 Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()
Previous Message Christian Kruse 2014-01-30 08:32:52 Re: Regression tests failing if not launched on db "regression"