From: SourceForge.net <no...@so...> - 2012-08-22 19:35:42
|
Bugs item #3560781, was opened at 2012-08-22 12:35 Message generated for change (Tracker Item Submitted) made by You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=3560781&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: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: DavidEGrayson () Assigned to: Nobody/Anonymous (nobody) Summary: Incorrect line number reported for error 2: Initializer elem Initial Comment: I am using Windows 7 64-bit and my sdcc -v is: SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08 3.2.0 #8008 (Jul 6 2012) (MINGW32) The test code that reproduces the bug is: const char x = 0; char foo(){ return 4; } void main() { static const char a = foo(); static const char b = a; } static const char c = foo(); static const char d = c; When I compile the code by running "sdcc test.c", I get the following output: test.c:1: error 2: Initializer element is not constant test.c:1: error 2: Initializer element is not constant test.c:1: error 2: Initializer element is not constant test.c:11: error 2: Initializer element is not constant test.c:12: error 2: Initializer element is not constant test.c:12: error 2: Initializer element is not constant Clearly there is no error on line 1, so one bug is that SDCC reports the wrong line number. The errors it is reporting on line 1 are actually caused by the definitions of a and b. SDCC generates two errors for b, and I would consider that to be another bug. If I compile with SDCC 3.1.0 #7066, then the errors for a and b go away and the output is just: test.c:11: error 2: Initializer element is not constant test.c:12: error 2: Initializer element is not constant test.c:12: error 2: Initializer element is not constant If I comment out c and d, then SDCC 3.1.0 #7066 compiles the program correctly, putting some code in the GSINIT section to call foo and initialize a and b. This was a nice feature and I had some existing code that relied on it. Clearly something about static const local variables has changed between SDCC 3.1.0 and 3.2.0, and I am not sure if it is a bug. However, the new errors are consistent with gcc: I tested compiling the code with gcc and it gives errors for a, b, c, and d. I checked the change log on the front page of http://sdcc.sourceforge.net/ and the only possibly relevant entry was: "inclusion of some tests from the gcc test suite into the sdcc regression test suite led to many bugs being found and fixed." Does anyone know what changed to cause these new errors? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=3560781&group_id=599 |