This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
Re: redboot fconfig crash with gcc 4.3.2
Gary Thomas <gary@mlbassoc.com> writes:
> Jose Vasconcellos wrote:
>> Redboot gets an exception when trying to set any IP address with fconfig
>> when using gcc-4.3.2 on an ixp425 target (armeb). The issue seems to be
>> an alignment problem as val_ptr contains an odd address; it looks like gcc
>> is optimizing and trying to do a copy on a word boundary. The removal of
>> the cast fixes the problem.
>>
>>
>> --- fconfig.c 2009-01-18 14:34:11.000000000 -0500
>> +++ fconfig.c.new 2009-01-18 14:35:22.000000000 -0500
>> @@ -388,7 +388,7 @@
>> break;
>> #ifdef CYGPKG_REDBOOT_NETWORKING
>> case CONFIG_IP:
>> - memcpy(&hold_ip_val.s_addr, &((in_addr_t
>> *)val_ptr)->s_addr, sizeof(in_addr_t));
>> + memcpy(&hold_ip_val.s_addr, val_ptr, sizeof(in_addr_t));
>> if (!_gethostbyname(line, &new_ip_val)) {
>> return CONFIG_BAD;
>> }
>>
>
> Sounds like a *BUG* in the compiler.
I don'think so -- standard behaviour is undefined when converting from a
pointer to one type to a pointer to another type that has more stringent
alignment requirements (e.g. from "void *" to "in_addr_t *").
Regards,
--
Daniel Néri <daniel.neri@sigicom.com>
Sigicom AB, Stockholm, Sweden