This is the mail archive of the gcc@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]

Re: aliasing warnings [patch]



  |> I think your idea is probably a good one, but your statement is not
  |> 100% correct.  Consider:
  |> 
  |>   int i;
  |>   int *ip = &i;
  |>   double *dp = (double *) ip;
  |>   int *ip2 = (int*) dp;
  |> 
  |>   *ip2 = 3;

  If i is not correctly aligned for double then the behaviour is undefined
  (C9x 6.3.2.3 [#7]).  Thus this may not be valid, independent of aliasing
  issues.

Of course.  (Actually, aren't pointer casts undefined only if the
number of bits used to represent the pointers are different?  I
thought the behavior was just implementation-defined, otherwise.  But,
I believe you.)

But, we've already agreed to forgo discussing alignment issues when
discussing these aliasing questions.  Let's not get sidetracked from
the core issue.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

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