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

From Andres Freund
Subject Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()
Date
Msg-id 20140128212242.GF18333@awork2.anarazel.de
Whole thread Raw
In response to Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2014-01-28 16:19:11 -0500, Tom Lane wrote:
> Christian Kruse <christian@2ndQuadrant.com> writes:
> > According to http://llvm.org/bugs/show_bug.cgi?id=18644#c5 this is not
> > a compiler bug but a difference between gcc and clang. Clang seems to
> > use a left-to-right order of evaluation while gcc uses a right-to-left
> > order of evaluation. So if errmsg changes errno this would lead to
> > errno == ENOMEM evaluated to false.
> 
> Oh!  Yeah, that is our own bug then.

Pretty nasty too. Surprising that it didn't cause more issues. It's not
like it would only be capable to cause problems because of the
evaluation order...

> > Should we work on this issue?
> 
> Absolutely.  Probably best to save errno into a local just before the
> ereport.

I think just resetting to edata->saved_errno is better and sufficient?

Greetings,

Andres Freund

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



pgsql-hackers by date:

Previous
From: Jason Petersen
Date:
Subject: Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()
Next
From: Robert Haas
Date:
Subject: Re: WIP patch (v2) for updatable security barrier views