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]
Other format: [Raw text]

Re: C question: typecast changes behavior with optimizations enabled.


Adam Dickmeiss <adam@indexdata.dk> writes:

> Consider the attached which sweeps through an array of chars..
> 
> 1) If a typecast is used (CAST defined), the *src is not updated and
> main will see (sz == 0).
> 
> 2) If no typecast is used, *src is updated, and size == 1.

1) Wrong mailing list.  This would be appropriate for gcc-help or for
   a list for general C language questions.

2) Looks like an aliasing problem.  Try compiling with
   -fno-strict-aliasing.  Look at the documentation for
   -fstrict-aliasing and -Wstrict-aliasing.

Ian


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