Menu

#2247 misc. compiler warnings on faulty and potetially faulty code in SDCCgen.c, ralloc.cc, asmain.c

closed-duplicate
nobody
None
Front-end
5
2015-03-11
2014-02-02
Kio
No

when compiling sdcc files SDCCgen.c and ralloc.cc emit warnings which in 2 cases point to programming errors and in others may do so.

frequent: ../SDCCgen.h:56:3: warning: anonymous structs are a Microsoft extension [-Wmicrosoft]

That's just stupid.

as can seen from the invocation gcc -fms-extensions -pipe -ggdb -Wno-deprecated -Wall -Wno-parentheses -I. -I.. -I./../support/util -I. -I. -c SDCCy.c -o SDCCy.o ms-extensions are enabled explicitely, but then the warning should be supressed at the same point as well.

at 2 points: SDCCopt.c:1122:101: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare]

i assume this is an error in both cases.

lots: ralloc2.cc:78:126: warning: '&&' within '||' [-Wlogical-op-parentheses]

i hope at least the original the programmer was aware of exact operator precedence in every case when he wrote this. for the sake of maintainability and to supress the warnings there should be brackets added.

once: ralloc2.cc:1437:15: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]

this may or may be not an error. brackets should be added in case this is an assignment.

at least the two comparisson bugs should be fixed.
for locations of warnings see attached file or just compile sdcc yourself and take a look at the compiler output!

tested with sdcc 3.3.0 and svn trunk head.

1 Attachments

Related

Bugs: #2279

Discussion

  • Philipp Klaus Krause

    Anonymous structs are also in the C11 standard. People writing a C compiler, such as sdcc can be assumed to know about operator precedence, so I don't think the warnings in ralloc2.cc require action.
    I'll have a look at the warning in SDCCopt.c.

    Philipp

     
  • Philipp Klaus Krause

    I fixed both warning about >= 0 comparisons in revision #8940.

    Philipp

     
  • Maarten Brock

    Maarten Brock - 2014-02-02

    I prefer adding the brackets to emphasize operator precedence for the human reader and to silence the warning.

    The anonymous struct warning is really stupid.

     
  • Ben Shi

    Ben Shi - 2015-03-11
    • status: open --> closed-duplicate
     
  • Ben Shi

    Ben Shi - 2015-03-11

    Duplicate to bug #2279.

     

Log in to post a comment.