[Bug c++/14029] [tree-ssa] Miscompilation of unrolled loop due to Iterator::base having an aliasing problem

pinskia at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Feb 6 03:11:00 GMT 2004


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-02-06 03:10 -------
This is caused by -fstrict-aliasing.

The problem is that C++ (and the C by the way if converted to act like C) front-end is doing this 
for Iterator::base :

int* const& Iterator::base() const (this)
{
  {
    return (int * const *)this;
  }
}

which is wrong as it violates aliasing rules.


For a C example:

int **t(struct Iterator*this1)
{
  return &this1->ptr;
}

Does this:
t (this1)
{
  return (int * *)this1;
}


Even it gets this wrong too:
struct Iterator {
    int * ptr;
    int * ptr1;
};
int **t(struct Iterator*this1)
{
  return &this1->ptr1;
}

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical
          Component|optimization                |c++
   Last reconfirmed|2004-02-05 18:37:03         |2004-02-06 03:10:57
               date|                            |
            Summary|[tree-ssa] Miscompilation of|[tree-ssa] Miscompilation of
                   |unrolled loop               |unrolled loop due to
                   |                            |Iterator::base having an
                   |                            |aliasing problem


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



More information about the Gcc-bugs mailing list