Code: Select all
Private Function GetValue(ByVal c1 as Integer) as Integer
If c1 <> 0 Then
GetValue = c1
End If
End Function
Code: Select all
Private Function GetValue(ByVal c1 as Integer) as Integer
If c1 <> 0 Then
GetValue = c1
End If
End Function
Yes, it should and it does here unless the compiler option --warn=no-undefined-var is specified. Check your .pjt file and the IDE user options file to see if that specific warning (or warnings in general) is being suppressed.mikep wrote:Shouldn't the following code at least issue a warning message about an uninitialized return value
Code: Select all
#pragma warning(push;undefined-var:on)
Private Function GetValue(ByVal c1 as Integer) as Integer
If c1 <> 0 Then
GetValue = c1
End If
End Function
#pragma warning(pop)
Code: Select all
foo.bas:12: Warning(2): "GetValue", not all paths set the return value
Or the routine is not referenced by other code. I suppose that this type of warning is issued by the code generation backend. No generation for dead code means no warning.dkinzer wrote:Yes, it should and it does here unless the compiler option --warn=no-undefined-var is specified.mikep wrote:Shouldn't the following code at least issue a warning message about an uninitialized return value
The warning is currently generated during the code generation phase and it uses information generated during the optimization phase. Since the optimization phase is only performed for procedures that appear in the call graph (i.e. those that are invoked), moving the warning to the optimization phase wouldn't help.mikep wrote:Or the routine is not referenced by other code.
A warning option for unused procedures could be added. It would be best, I believe, if it were not on by default as is the case for the warning for unused parameters.mikep wrote:A warning list of dead routines might be even better.