This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C question: typecast changes behavior with optimizations enabled.
- From: Ian Lance Taylor <iant at google dot com>
- To: Adam Dickmeiss <adam at indexdata dot dk>
- Cc: gcc at gcc dot gnu dot org
- Date: 26 Sep 2006 10:14:35 -0700
- Subject: Re: C question: typecast changes behavior with optimizations enabled.
- References: <451925A5.9060906@indexdata.dk>
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