12.07.2015 Views

MPLAB C32 C COMPILER USER'S GUIDE

MPLAB C32 C COMPILER USER'S GUIDE

MPLAB C32 C COMPILER USER'S GUIDE

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>MPLAB</strong> ® <strong>C32</strong> C Compiler User’s GuideTABLE 1-5:Option-Wmultichar-Wno-multichar-Wparentheses-Wreturn-type-Wsequence-pointWARNING AND ERROR OPTIONS IMPLIED BY-WALL (CONTINUED)DefinitionWarn if a multi-character character constant is used.Usually, such constants are typographical errors. Since theyhave implementation-defined values, they should not beused in portable code. The following example illustrates theuse of a multi-character character constant:charxx(void){return('xx');}Warn if parentheses are omitted in certain contexts, such aswhen there is an assignment in a context where a truth valueis expected, or when operators are nested whoseprecedence people often find confusing.Warn whenever a function is defined with a return-type thatdefaults to int. Also warn about any return statement withno return-value in a function whose return-type is not void.Warn about code that may have undefined semanticsbecause of violations of sequence point rules in the Cstandard.The C standard defines the order in which expressions in a Cprogram are evaluated in terms of sequence points, whichrepresent a partial ordering between the execution of parts ofthe program: those executed before the sequence point andthose executed after it. These occur after the evaluation of afull expression (one which is not part of a larger expression),after the evaluation of the first operand of a &&, ||, ? : or ,(comma) operator, before a function is called (but after theevaluation of its arguments and the expression denoting thecalled function), and in certain other places. Other than asexpressed by the sequence point rules, the order ofevaluation of subexpressions of an expression is notspecified. All these rules describe only a partial order ratherthan a total order, since, for example, if two functions arecalled within one expression with no sequence point betweenthem, the order in which the functions are called is notspecified. However, the standards committee has ruled thatfunction calls do not overlap.It is not specified, when, between sequence pointsmodifications to the values of objects take effect. Programswhose behavior depends on this have undefined behavior,The C standard specifies that “Between the previous andnext sequence point, an object shall have its stored valuemodified, at most once, by the evaluation of an expression.Furthermore, the prior value shall be read only to determinethe value to be stored.” If a program breaks these rules, theresults on any particular implementation are entirelyunpredictable.Examples of code with undefined behavior are a = a++;,a[n] = b[n++] and a[i++] = i;. Some morecomplicated cases are not diagnosed by this option, and itmay give an occasional false positive result, but in general ithas been found fairly effective at detecting this sort ofproblem in programs.DS51686A-page 20© 2007 Microchip Technology Inc.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!