This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/13472] [3.3 Regression] optimizer generates code to store data in const int, resulting in a segfault


------- Additional Comments From ebotcazou at gcc dot gnu dot org  2003-12-23 14:19 -------
The final culprit is the reload pass: it generates the store (although the MEM
is marked as unchanging) because it thinks the memory location is a regular
spill slot.  It appears that the reload pass doesn't care about the /u flag when
recording equivalent memory locations based on the presence of REG_EQUIV notes.

But I don't know if this is really a reload problem: maybe reload implicitly
expects full equivalence between objects in pairs that carry REG_EQUIV notes.

In any cases, the dependence upon -pedantic is certainly a bug and is actually
recognized as such in the code (c-typeck.c:790):

/* Return either DECL or its known constant value (if it has one), but
   return DECL if pedantic or DECL has mode BLKmode.  This is for
   bug-compatibility with the old behavior of decl_constant_value
   (before GCC 3.0); every use of this function is a bug and it should
   be removed before GCC 3.1.  It is not appropriate to use pedantic
   in a way that affects optimization, and BLKmode is probably not the
   right test for avoiding misoptimizations either.  */

static tree
decl_constant_value_for_broken_optimization (decl)
     tree decl;
{
  if (pedantic || DECL_MODE (decl) == BLKmode)
    return decl;
  else
    return decl_constant_value (decl);
}


So I think the fix is to remove decl_constant_value_for_broken_optimization
altogether from the C front-end.  But this is probably not doable on a release
branch.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |ebotcazou at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13472


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]