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

From Tom Lane
Subject Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()
Date
Msg-id 4904.1390943951@sss.pgh.pa.us
Whole thread Raw
In response to Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()  (Christian Kruse <christian@2ndQuadrant.com>)
Responses Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers
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.

> Should we work on this issue?

Absolutely.  Probably best to save errno into a local just before the
ereport.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Christian Kruse
Date:
Subject: Re: Suspicion of a compiler bug in clang: using ternary operator in ereport()
Next
From: Alvaro Herrera
Date:
Subject: Re: Patch: regexp_matches variant returning an array of matching positions