From: SourceForge.net <no...@so...> - 2008-10-17 10:32:11
|
Bugs item #2166213, was opened at 2008-10-14 16:03 Message generated for change (Comment added) made by patryks You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2166213&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: Andreas Gustafsson (gson) Assigned to: Nobody/Anonymous (nobody) Summary: warning 18: Initializer different levels of indirections Initial Comment: Compiling the following program: struct a { int i; }; struct b { int i; }; __code struct a s = { 0 }; __code struct b * __code p = (__code struct b *) &s; with "sdcc -c test.c" using SDCC 2.6.0 produces the following warning: test2.c:4: warning 18: Initializer different levels of indirections from type 'const-struct a code-const-code* ' to type 'const-struct b code-const-code* ' I believe the warning is incorrect; there are no different levels of indirections involved in the initialization, and the two last lines of the warning message seem to bear this out as they both contain exactly one asterisk. Removing the second "__code" of the three on the last line of the program makes the warning go away. ---------------------------------------------------------------------- Comment By: Patryk (patryks) Date: 2008-10-17 12:32 Message: > No, it shouldn't; the types involved in the initialization are both > "_code struct b *" (because of the cast). Agree: __code struct b * __code p = (__code struct b *)0x1234; generates no warning. ---------------------------------------------------------------------- Comment By: Andreas Gustafsson (gson) Date: 2008-10-17 12:23 Message: > It should warn you instead that struct a does not equal struct b No, it shouldn't; the types involved in the initialization are both "_code struct b *" (because of the cast). ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2008-10-17 12:06 Message: Andreas, The warning is incorrect. It should warn you instead that struct a does not equal struct b. Maarten ---------------------------------------------------------------------- Comment By: Patryk (patryks) Date: 2008-10-16 09:46 Message: Agree. Const implied by __code also doesn't metter there. ---------------------------------------------------------------------- Comment By: Andreas Gustafsson (gson) Date: 2008-10-15 16:14 Message: > Shouldn't you put one more __code in your last line? I don't think it makse sense to apply a storage class like __code to an rvalue. ---------------------------------------------------------------------- Comment By: Patryk (patryks) Date: 2008-10-15 10:21 Message: Shouldn't you put one more __code in your last line? __code struct b * __code p = (__code struct b *) &s; __code struct b * __code p = (__code struct b * __code) &s; Anyway causes the same warning. I experienced the same problem somewhere in my code. __code implies const, and SDCC got some long lasting problems with it, especially when used with pointers. See: [ 1458678 ] unsigned long *const w, xtea stream cypher https://sourceforge.net/tracker2/index.php?func=detail&aid=1458678&group_id=599&atid=100599 (and comments leading to other cases). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2166213&group_id=599 |