Bug#716635: gcc-4.8: Miscompilation at optimization -O1
tag 716635 - help
tag 716635 + upstream
forwarded 716635 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59137
retitle 716635 gcc-4.8: Miscompilation at optimization -O1 on mips/mipsel
thanks
On Wed, Jul 10, 2013 at 04:28:46PM -0400, Camm Maguire wrote:
>
> Package: gcc-4.8
> Version: 4.8.1-5
> Severity: important
>
> The following code
>
> type_of(x0)==t_cons
>
> from
>
> DEFUNO_NEW("LISTP",object,fLlistp,LISP
> ,1,1,NONE,OO,OO,OO,OO,void,Llistp,(object x0),"")
>
> {
> /* 1 args */
>
> if (x0 == Cnil || type_of(x0) == t_cons)
> x0 = Ct;
> else
> x0 = Cnil;
> RETURN1(x0);
> }
>
> where type_of(x0) is fully expanded as
>
> ({register object _z=(object)(x0); ((((ufixnum)(_z))>=0x80000000) ?
> t_fixnum : ((!(_z)->d.e || (((ufixnum)((*(object *)(_z))))>=0x80000000))
> ? (_z==((object)&Cnil_body) ? t_symbol : t_cons) : _z->d.t));})
>
> incorrectly gives true when compiled at O1, and correctly gives false
> when compiled at -O0 (only on mips).
>
> The following is a gdb session followed by the full preprocessed source.
>
Attached is a reduced testcase. The problem does appear at -O1, but not
at -O0 nor -O2. It is reproducible with GCC 4.7, 4.8 or snapshot, but
not with 4.6 or older. I have reported it upstream as issue #59137.
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
struct lispstruct
{
int e;
int t;
};
struct lispstruct Cnil_body;
struct lispstruct Ct_body;
int nvalues;
struct lispstruct * fLlistp (struct lispstruct *x0)
{
if (x0 == &Cnil_body || (((unsigned long) x0 >= 0x80000000) ? 0 : (!x0->e ? (x0 != &Cnil_body) : x0->t)))
x0 = &Ct_body;
else
x0 = &Cnil_body;
nvalues = 1;
return x0;
}
int main ()
{
return fLlistp((struct lispstruct *) 0xa0000001) == &Cnil_body;
}
Reply to: