Bugs item #2806238, was opened at 2009-06-14 17:44
Message generated for change (Settings changed) made by maartenbrock
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2806238&group_id=599
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
>Category: C-Front End
>Group: fixed
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: dfulab (dfulab)
Assigned to: Maarten Brock (maartenbrock)
Summary: pointer to function becomes NULL in struct
Initial Comment:
Compiler: SDCC 2.9.0 #5416 (Mar 22 2009) (MINGW32)
This is can either classified as a silence failure or code generation error.
I have a table of pointer to functions in a const struct.
A few of them have a mismatched types than the struct declaration. e.g. returns a value vs void
I have simplified the code to bare minimum to show this error.
The compiler silently replaces the pointers to these function to 0x0000, but issue no warning messages.
My prefence would have been a warning message, but still having the pointers to the offending function as this is closest to user intents. If the compiler wants to be straight about this, then there should be an error message.
compile command line:
"C:\Program Files\SDCC\bin\sdcc" -mz80 -c fail.c
Source Code: fail.c (also attached)
-------------------------------------------------------------------------
void fun1(void)
{}
char fun2(void)
{ return(123); }
typedef struct
{ void (*func)(void);
} calltbl;
const calltbl table[]=
{ { fun1 },
{ fun2 }
};
-------------------------------------------------------------------------
Assembly listing: fail.lst
--------------------------------------------------------------------------
44 .area _CODE
45 ;fail.c:1: void fun1(void)
46 ; ---------------------------------
47 ; Function fun1
48 ; ---------------------------------
49 _fun1_start::
50 _fun1:
51 ;fail.c:2: {}
52 ret
53 _fun1_end::
54 ;fail.c:4: char fun2(void)
55 ; ---------------------------------
56 ; Function fun2
57 ; ---------------------------------
58 _fun2_start::
59 _fun2:
60 ;fail.c:5: { return(123); }
61 ld l,#0x7B
62 ret
63 _fun2_end::
64 .area _CODE <-- const structure is declared here
66 .dw _fun1 <-- pointer to fun1()
67 .dw 0x0000 <-- supposed to be pointer to fun2(), but get a NULL here when function has a type mismatched !
68 .area _CABS
----------------------------------------------------------------------
>Comment By: Maarten Brock (maartenbrock)
Date: 2009-10-28 21:48
Message:
Fixed in SDCC 2.9.4 #5557
----------------------------------------------------------------------
Comment By: Patryk (patryks)
Date: 2009-09-21 09:17
Message:
It may me the same as #1928022:
ROM pointer to struct member not initialized
----------------------------------------------------------------------
Comment By: Philipp Krause (spth)
Date: 2009-09-20 15:32
Message:
All ports are affected by this bug.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2806238&group_id=599
|