Possible Compiler Error 
Author Message
 Possible Compiler Error

Should not the following create a compiler error instead of a runtime error?

dim inx as integer

for inx = 1 to 90000
    ...
next

--
Harold S.



Sun, 04 Mar 2001 03:00:00 GMT  
 Possible Compiler Error

Quote:

>Should not the following create a compiler error instead of a runtime
error?

>dim inx as integer

>for inx = 1 to 90000
>    ...
>next

Not necessarily.  The loop might never iterate enough times to cause
the overflow (e.g., you could do an "Exit For" before the overflow
occured.)  Compiler errors only occur when there are problems in the
code that are guaranteed to always cause errors.

--- Russell Davis



Sun, 04 Mar 2001 03:00:00 GMT  
 Possible Compiler Error

Quote:


>>Should not the following create a compiler error instead of a runtime
>error?

>>dim inx as integer

>>for inx = 1 to 90000
>>    ...
>>next

>Not necessarily.  The loop might never iterate enough times to cause
>the overflow (e.g., you could do an "Exit For" before the overflow
>occured.)  Compiler errors only occur when there are problems in the
>code that are guaranteed to always cause errors.

That last sentence is probably a bit OTT, Russ. And a C programmer would
certainly expect at least a Warning from her compiler for that sort of
syntax.

Harold, as an aside, if you're 32-bitting then avoid integers anyway as they
are slower than longs.

Bertie



Mon, 05 Mar 2001 03:00:00 GMT  
 Possible Compiler Error

Quote:


>>Should not the following create a compiler error instead of a runtime
>error?

>>dim inx as integer

>>for inx = 1 to 90000
>>    ...
>>next

>Not necessarily.  The loop might never iterate enough times to cause
>the overflow (e.g., you could do an "Exit For" before the overflow
>occured.)  Compiler errors only occur when there are problems in the
>code that are guaranteed to always cause errors.

>--- Russell Davis

This in not true because the error occurs on the For statement prior to
executing any of the statements in the for loop. So this tells me that the
compiler should catch this error.

Harold S.



Mon, 05 Mar 2001 03:00:00 GMT  
 Possible Compiler Error
Thanks for the tip Bertie.

--
Harold S.

Quote:



>>>Should not the following create a compiler error instead of a runtime
>>error?

>>>dim inx as integer

>>>for inx = 1 to 90000
>>>    ...
>>>next

>>Not necessarily.  The loop might never iterate enough times to cause
>>the overflow (e.g., you could do an "Exit For" before the overflow
>>occured.)  Compiler errors only occur when there are problems in the
>>code that are guaranteed to always cause errors.

>That last sentence is probably a bit OTT, Russ. And a C programmer would
>certainly expect at least a Warning from her compiler for that sort of
>syntax.

>Harold, as an aside, if you're 32-bitting then avoid integers anyway as
they
>are slower than longs.

>Bertie



Mon, 05 Mar 2001 03:00:00 GMT  
 Possible Compiler Error
No type range checking is done
try this
Dim n As Integer
  n = 567567567
  n = Null
  n = "ffefef"
it all compiles ok
Quote:



>>>Should not the following create a compiler error instead of a runtime
>>error?

>>>dim inx as integer

>>>for inx = 1 to 90000
>>>    ...
>>>next

>>Not necessarily.  The loop might never iterate enough times to cause
>>the overflow (e.g., you could do an "Exit For" before the overflow
>>occured.)  Compiler errors only occur when there are problems in the
>>code that are guaranteed to always cause errors.

>>--- Russell Davis

>This in not true because the error occurs on the For statement prior to
>executing any of the statements in the for loop. So this tells me that the
>compiler should catch this error.

>Harold S.



Sun, 11 Mar 2001 03:00:00 GMT  
 Possible Compiler Error
My point exactly.

--
Harold S.

Quote:

>No type range checking is done
>try this
>Dim n As Integer
>  n = 567567567
>  n = Null
>  n = "ffefef"
>it all compiles ok




>>>>Should not the following create a compiler error instead of a runtime
>>>error?

>>>>dim inx as integer

>>>>for inx = 1 to 90000
>>>>    ...
>>>>next

>>>Not necessarily.  The loop might never iterate enough times to cause
>>>the overflow (e.g., you could do an "Exit For" before the overflow
>>>occured.)  Compiler errors only occur when there are problems in the
>>>code that are guaranteed to always cause errors.

>>>--- Russell Davis

>>This in not true because the error occurs on the For statement prior to
>>executing any of the statements in the for loop. So this tells me that the
>>compiler should catch this error.

>>Harold S.



Sun, 11 Mar 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. COMPILER ERROR - POSSIBLE VB BUG

2. Possible command line compiler bug?

3. Compiler switches for MS Basic Compiler 5.35

4. Compiler's..,Compiler's Explain

5. VBA compiler VS VB5 compiler?

6. Compiler error. Cannot find project or library

7. Compiler error

8. Compiler error in module autoexec

9. attn MSFT: annoying invisible compiler errors in VB.NET 2003

10. VB .NET compiler unable to recover from this error (SP2 is installed)

11. Internal compiler error

12. The compiler failed with error code 128

 

 
Powered by phpBB® Forum Software