Hi all

While playing around with the Contiki OS, I came across something that left
me scratching my head for a while... I stripped it down to something small
that will still exhibit the same behaviour. I was about to file a bug report
but thought I'd double check that it's not bad code for some reason that
I've failed to spot

The attached will compile just fine with:
sdcc -c foo.c

However, if we compile with --stack-auto, we get the following error:

geo@lin-geo:~/workspace/test-proj$ sdcc --stack-auto -c foo.c
foo.c:19: error 78: incompatible types
from type 'unsigned-char generic* auto'
to type 'struct ip6_addr generic* fixed'

As anticipated, if we add __reentrant to foo's prototype and compile
without --stack-auto we get the same error. --model-xyz does not make any
difference that I've noticed (tried small, large, huge)

However, if we make any of the following changes (demonstrated in the
attached), --stack-auto works
- If foo returns void *
- If we cast its return value to (void *)
- If it takes only a single argument
- If it takes two arguments but neither of type struct xyz *

I tried with the following versions:
SDCC : mcs51 3.0.4 #6748 (Aug 17 2011) (Linux)
SDCC : mcs51 3.0.4 #6726 (Aug  8 2011) (Mac OS X x86_64)
SDCC : mcs51 3.0.1 #6188 (Feb  3 2011) (CYGWIN)
(can you tell how often I use cygwin???):

As ever, folks, thanks a lot for your time reading this and even more so for
all the efforts maintaining SDCC
geo

Attachment: foo.c
Description: Binary data

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to