[partial backport of gcc-4.9/trunk r198344 to fix a target-breaking typo in LRA ] List-Archive: Date: Tue, 09 Jul 2013 22:51:16 +0100 From: David Given Subject: HAVE_ATTR_enabled mishandling? I think I have found a bug. This is in stock gcc 4.8.1... My backend does not use the 'enabled' attribute; therefore the following code in insn-attr.h kicks in: #ifndef HAVE_ATTR_enabled #define HAVE_ATTR_enabled 0 #endif Therefore the following code in gcc/lra-constraints.c is enabled: #ifdef HAVE_ATTR_enabled if (curr_id->alternative_enabled_p != NULL && ! curr_id->alternative_enabled_p[nalt]) continue; #endif ->alternative_enabled_p is bogus; therefore segfault. Elsewhere I see structures of the form: #if HAVE_ATTR_enabled ... #endif So I think that #ifdef above is a straight typo. Certainly, changing it to a #if makes the crash go away... List-Archive: Date: Fri, 12 Jul 2013 02:35:53 +0800 From: Chung-Ju Wu Subject: Re: HAVE_ATTR_enabled mishandling? I faced exactly the same problem as yours. When I was trying to enable LRA on my target, I got segfault as well because I did not have 'enabled' attribute in my target.md file. I was told it was due to my faulty md design. The simplest workaround is to define 'enabled' attribute so I took it. But I suspected that may be a latent issue. It's so happy to see others have the same question and provide a solution. Certainly, whether your solution is correct should be reviewed by LRA maintainer, Vladmir Makarov, so I cc him in the list. gcc/ 2013-04-26 Vladimir Makarov * lra-constraints.c (process_alt_operands): Use #if HAVE_ATTR_enabled instead of #ifdef. --- gcc-4.8.1/gcc/lra-constraints.c.~1~ 2013-05-02 21:16:29.000000000 +0200 +++ gcc-4.8.1/gcc/lra-constraints.c 2013-07-13 09:38:03.060435343 +0200 @@ -1388,7 +1388,7 @@ process_alt_operands (int only_alternati for (nalt = 0; nalt < n_alternatives; nalt++) { /* Loop over operands for one constraint alternative. */ -#ifdef HAVE_ATTR_enabled +#if HAVE_ATTR_enabled if (curr_id->alternative_enabled_p != NULL && ! curr_id->alternative_enabled_p[nalt]) continue;