Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-09

Known issue with 1.9.4 [2004/05/30] for i386 on Linux?

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alan Mead

I don't know if this is really a bug or whether it's known... I have this line of code:

  while ( (i<=Length(fmt)) and (NOT fmt[i] IN ['0'..'9']) ) do
inc(i);

It compiles fine but I get a RTE:

An unhandled exception occurred at 0x0807B180 :
EVariantError : Invalid variant operation
$0807B180
$BFFFF980

Funny thing is, I enabled line numbers with '-gl'... And the error message makes no sense to me.. After staring at that line of code for a while, I put parens around the "fmt[i] IN ['0'..'9']" and all was well:

  while ( (i<=Length(fmt)) and (NOT (fmt[i] IN ['0'..'9'])) ) do
inc(i);

So, that seems to be a bug to me... Shall I report it or is it known (or am I wrong that it's a bug)?

-Alan

Reply by email

Marcel Martin
to Alan Mead
Alan Mead wrote 13 lines
I don't know if this is really a bug or whether it's known... I have this line of code: while ( (i<=Length(fmt)) and (NOT fmt[i] IN ['0'..'9']) ) do inc(i); It compiles fine but I get a RTE: An unhandled exception occurred at 0x0807B180 : EVariantError : Invalid variant operation $0807B180 $BFFFF980

Try with

  while ( (i<=Length(fmt)) and (NOT (fmt[i] IN ['0'..'9'])) ) do
                                    ^                    ^
                                    (                    )

i.e., with two parenthesis more.

mm http://www.ellipsa.net/ ( suppress no.sp.am. )

Reply by email

Marcel Martin
to Alan Mead: I don't know if this is really a bug or whether it's known... I have this line of code:…
Alan Mead wrote 24 lines
I don't know if this is really a bug or whether it's known... I have this line of code: while ( (i<=Length(fmt)) and (NOT fmt[i] IN ['0'..'9']) ) do inc(i); It compiles fine but I get a RTE: An unhandled exception occurred at 0x0807B180 : EVariantError : Invalid variant operation $0807B180 $BFFFF980 Funny thing is, I enabled line numbers with '-gl'... And the error message makes no sense to me.. After staring at that line of code for a while, I put parens around the "fmt[i] IN ['0'..'9']" and all was well: while ( (i<=Length(fmt)) and (NOT (fmt[i] IN ['0'..'9'])) ) do inc(i); So, that seems to be a bug to me... Shall I report it or is it known (or am I wrong that it's a bug)?

Sorry, I didn't understand the end of your post. It would be much easier in French :-))

mm http://www.ellipsa.net/ ( suppress no.sp.am. )

Reply by email

David Emerson
to Alan Mead: I don't know if this is really a bug or whether it's known... I have this line of code:…

I believe that your code is being interpreted as:

(NOT fmt[i]) in ['0'..'9']

instead of the intended NOT (fmt[i] in ['0'..'9'])

Pascal's rules for parsing logical expressions differ from the standard rules of the propositional calculus (i.e. modern symbolic logic). Thus, this behavior is "by design" -- you'll have to use those extra parens -- and don't bother filing a bug.

Incidentally, I happen to agree with your assesment that this is a bug, in the philosophical sense -- but it was designed that way by Nicklaus Wirth, so we're stuck with it. It's one of a few flaws in what's really a very beautiful programming language.

~David.

you wrote 25 lines
I don't know if this is really a bug or whether it's known... I have this line of code: while ( (i<=Length(fmt)) and (NOT fmt[i] IN ['0'..'9']) ) do inc(i); It compiles fine but I get a RTE: An unhandled exception occurred at 0x0807B180 : EVariantError : Invalid variant operation $0807B180 $BFFFF980 Funny thing is, I enabled line numbers with '-gl'... And the error message makes no sense to me.. After staring at that line of code for a while, I put parens around the "fmt[i] IN ['0'..'9']" and all was well: while ( (i<=Length(fmt)) and (NOT (fmt[i] IN ['0'..'9'])) ) do inc(i); So, that seems to be a bug to me... Shall I report it or is it known (or am I wrong that it's a bug)? -Alan

Reply by email

Alan Mead
to Alan Mead: I don't know if this is really a bug or whether it's known... I have this line of code:…
Alan Mead wrote 26 lines
I don't know if this is really a bug or whether it's known... I have this line of code: while ( (i<=Length(fmt)) and (NOT fmt[i] IN ['0'..'9']) ) do inc(i); It compiles fine but I get a RTE: An unhandled exception occurred at 0x0807B180 : EVariantError : Invalid variant operation $0807B180 $BFFFF980 Funny thing is, I enabled line numbers with '-gl'... And the error message makes no sense to me.. After staring at that line of code for a while, I put parens around the "fmt[i] IN ['0'..'9']" and all was well: while ( (i<=Length(fmt)) and (NOT (fmt[i] IN ['0'..'9'])) ) do inc(i); So, that seems to be a bug to me... Shall I report it or is it known (or am I wrong that it's a bug)?

Thanks for the comments. Perhaps I was unclear. There are three reasons I am inclined to consider this a bug.

First, it seems improper for any syntax to compile (i.e., to fail to raise a syntax error) and then not execute. Ok, "a := 1/0;" might compile but it seems like some type checking got lost here. Maybe there is am implicit conversion going on... At the least, I'd like the compiler to flag this line with a warning.

Second, I had to track this down by inserting a bunch of lines like "writeln('Passed 33');". The code was compiled with -gl so I should see a line number but none is shown. This seems like a bug.

Third, the RTE, "Invalid variant operation" seems inappropriate and confusing. Again, maybe there's an implicit conversion... (but is it appropriate?)

-Alan

Reply by email

Nico Aragón
to Alan Mead

Hello,

Alan Mead wrote
> while ( (i<=Length(fmt)) and (NOT fmt[i] IN ['0'..'9']) ) do > inc(i); First, it seems improper for any syntax to compile (i.e., to fail to raise a syntax error) and then not execute.

It compiles because it has the meaning that David said. The "not" operator is applied to fmt[i].

Show quoted text 7 lines
Second, I had to track this down by inserting a bunch of lines like "writeln('Passed 33');". The code was compiled with -gl so I should see a line number but none is shown. This seems like a bug. Third, the RTE, "Invalid variant operation" seems inappropriate and confusing. Again, maybe there's an implicit conversion... (but is it appropriate?)

The "not" operator applies to integers, performing a bitwise not. In your code it's applied to a character, so the conversion is probably from char to integer. Useful when doing f.i. compression or encryption.

If it's inappropiate or not, I don't know.

saludos, Nico Aragón NOTE: na-list address only works for messages coming from lists. Please, write to "nico" at the same domain for direct email.

Reply by email