Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Impossible "integer expression" errors

  1. #1

    Impossible "integer expression" errors

    I've been making my own list class that is generic and uses a variety of optimized methods. Unfortunately, though, I now get "invalid integer expression" errors at 5+ locations and cannot test the unit. Worse, these errors are ... inane.

    These are all integer operations that work, yet generated errors. See for yourself.

    Line 87 Column 9:
    Code:
      B := -1;  // -1 is within the integer range I'm familiar with!
    Line 116 Column 14:
    Code:
      if idx <> -1 then
    Line 127 Column 14:
    Code:
      if idx <> -1 then
    Line 194 Column 12:
    Code:
      Find &#58;= -1; // assignment to "result"
    Line 235 Column 11:
    Code:
      if F = -1 then Exit;
    Have I done something particularly crash-worthy? The source code (11kb) is under MPL.

    Compiler options of note:
    Dialect = Object Pascal (FPC)
    Optimization = Faster Code

  2. #2

    Impossible "integer expression" errors

    That's some funky stuff there. Must be a compiler bug. It compiles if you write 0-1 instead of -1 though
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  3. #3

    Impossible "integer expression" errors

    You're kidding! 0-1 works? Maybe typecast it to an integer and it'll work then.

    http://bugs.freepascal.org/view.php?id=11035

  4. #4

    Impossible "integer expression" errors

    Okay, this appears to be a bug in generic types for FPC 2.2.0, but is fixed in 2.2.1. If only 2.2.1 was the front page release that was marked as stable, rather than the 2.2.0 release.

    Edit: Still broken; reopening ticket.

  5. #5

    Impossible "integer expression" errors

    And it compiles when you put 0-1 for -1, yes, but it won't run because of:
    Code:
    An unhandled exception occurred at $004016C3 &#58;
    ERangeError &#58; Range check error
      $004016C3
      $00401BA8
      $00401FB2
    No idea how to even work around this.

  6. #6

    Impossible "integer expression" errors

    It compiles and runs fine for me in version 2.2.0
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  7. #7

    Impossible "integer expression" errors

    Well, with 2.2.1 it produces that range check error, as you see, and chokes and dies. So I'll have to revert. Looks like their hack isn't nearly so stable as they thought it was. :?

    The website is horribly slow, so I'm having trouble posting that addendum with the additional 2.2.1 trouble.

  8. #8

    Impossible "integer expression" errors

    does not compile here

    From brazil (:

    Pascal pownz!

  9. #9

    Impossible "integer expression" errors

    Mode must be "Object Pascal extension on" under Options > Compiler.

  10. #10

    Impossible "integer expression" errors

    Compiles and runs fine with 2.2.1 here, I get all success 1 failure (as expected, since you go to .Count not .Count - 1).

    I uses -O2 -S2 -XX -Xs for options.

    With range check on I get some errors, but they seemed to be valid (I got none of the -1 problems). For example your code:
    Code:
    if AnsiCompareText&#40;fNames&#91;I&#93;, fNames&#91;I+1&#93;&#41; > 0 then begin
    Which is on line 112 of uFastList.pas is broken, because I + 1 is 1 too big for fNames. So the range check worked fine there.
    Feel the power of Open Source.
    <br />Feel the power of Free Pascal.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •