|Semantic Checking - C email@example.com (johnvoltaire) (2005-01-30)|
|Re: Semantic Checking - C firstname.lastname@example.org (2005-02-03)|
|Re: Semantic Checking - C email@example.com (2005-02-03)|
|Re: Semantic Checking - C firstname.lastname@example.org (Jeremy Wright) (2005-02-03)|
|Re: Semantic Checking - C email@example.com (jacob navia) (2005-02-03)|
|Re: Semantic Checking - C firstname.lastname@example.org (Neal Wang) (2005-02-03)|
|Re: Semantic Checking - C email@example.com (Tommy Thorn) (2005-02-03)|
|Re: Semantic Checking - C firstname.lastname@example.org (2005-02-11)|
|From:||jacob navia <email@example.com>|
|Date:||3 Feb 2005 22:42:27 -0500|
|Organization:||les newsgroups par Wanadoo|
|Posted-Date:||03 Feb 2005 22:42:27 EST|
Here are some hints from the lcc-win32 compiler
> Common semantic errors in C language:
> 1. Use of function without function prototypes
lcc-win32 reports this as a warning.
> 2. Code with no effect (dead code)
lcc-win32 reports an assignment that is not used further
in the program. Other dead code could be reported if more
was done in this direction.
> 3. Division by zero
This is detected at compile time when the division is made
by two compile-time constants. Code could be generated at
run time to check division.
> 4. Use of functions and variables which are defined but not used
lcc-win32 reports this when the function/variable is static.
For non-static variables, this is done by the lcc-win32's linker
> 5. Use of functions and variables with defined arguments that are never
This is reported and easy to detect.
> 6. Use of functions and variables that return either with or without
> any assigned value
A warning is issued when a function declared as returning a value
doesn't return one.
> 7. Use of functions and variables that return values that are never
This is not reported but could be done. If you want this, it would be
very difficult, since this is common practice:
doesn't use the return value of printf but it is valid code.
> 8. Subscript out of bounds
I have been arguing in this group (and in the standards discussion
group) about the necessity of doing this. The problem is that
you would need a new kind of pointers, (bounded pointers) that
would carry size information.
> 9. Booleans that always evaluate true or evaluate false
lcc-win32 forces this. Any boolean is casted to 1 or zero.
> 10. Checking of infinite loops as well as loops that cannot be exited
> or entered
lcc-win32 checks this.
> 11. Statements that cannot be reached during execution
lcc-win32 checks this
> 12. No identifiers or variables are used twice in the same block or
lcc-win32 will warn you that a higher scope variable is shadowed
if you request this type of warnings.
> 13. The number and types of arguments in a function call must be the
> same as the number and types of the prototypes
This is checked
> 14. A return statement must not have a return value unless it appears
> in the function prototype that is declared to return a value
The same as item 6.
> 15. Break statements appear outside enclosing constructs where a break
> statement may appear
This is a syntax error
> 16. Elements of enumerated types are repeated
This is an error. It stops compilation.
> 17. Variable names appear in the same lexical scope
I suppose that you mean identical variable names. This is an error
> 18. Labels are repeated
The same error as 15: redefinition, syntax error. Compilation stops
Feel free to write me if you want further details.
Return to the
Search the comp.compilers archives again.