Results 1 to 3 of 3

Thread: error or not error ?

  1. #1
    Member DirectuX's Avatar
    Join Date
    Oct 2018
    Location
    France
    Posts
    417
    Rep Power
    55

    Question error or not error ?

    Should this code raise an error ?

    uses "console"
    
    dim myvar as DWord = 1
    myvar = - myvar
    printl myvar
    WaitKey
    
    myvar is declared as an unsigned variable. Why is it allowed to compute something below 0 ?

    Edit: All the same, if you declare
    • a variable as byte and assign a value outside the 0-255 range
    • a variable as boolean that isn't %true nor %false



    Regarding this previous question and the last Petr's blog page,
    is there a list of all errors caught by thinBasic ?
    Last edited by DirectuX; 01-03-2020 at 19:34.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736
    Hi Sebastian,

    what are you observing is overflow. It is not unique to thinBASIC and some algorithms actually benefit from it - according to related article for example hashing algorithms, certain data structures (ring buffers, particularly) and even image codecs.

    As thinBASIC already has OPTION BOUNDCHECK ON / OPTION BOUNDCHECK OFF, maybe it would be nice to have something like that for OVERFLOW?


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3
    Member DirectuX's Avatar
    Join Date
    Oct 2018
    Location
    France
    Posts
    417
    Rep Power
    55
    Quote Originally Posted by Petr Schreiber View Post
    Hi Sebastian,

    what are you observing is overflow. It is not unique to thinBASIC and some algorithms actually benefit from it - according to related article for example hashing algorithms, certain data structures (ring buffers, particularly) and even image codecs.

    As thinBASIC already has OPTION BOUNDCHECK ON / OPTION BOUNDCHECK OFF, maybe it would be nice to have something like that for OVERFLOW?


    Petr
    From the article you mentioned:
    Quote Originally Posted by http://huonw.github.io/blog/2016/04/myths-and-legends-about-integer-overflow-in-rust View Post
    These overflow checks can be manually disabled or enabled independently of the compilation mode both globally and at a per-operation level. By checking for overflow in some modes, overflow bugs in Rust code are hopefully found earlier. Furthermore, code that actually wants wrapping behaviour is explicit about this requirement, meaning fewer false positives for both future static analyses and for code that enables overflow checking in all modes.
    Yes ! it would help hunting certain bugs. By the way, instructive article, as the one it cites is.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

Similar Threads

  1. Error 216
    By opel_howard in forum Free Pascal
    Replies: 0
    Last Post: 13-11-2010, 18:48
  2. Little error
    By Petr Schreiber in forum Module SDK (Power Basic version)
    Replies: 1
    Last Post: 30-06-2006, 17:17
  3. Little error
    By Petr Schreiber in forum Fixed or cleared errors in help material
    Replies: 3
    Last Post: 22-02-2006, 10:59

Members who have read this thread: 0

There are no members to list at the moment.

Tags for this Thread

Posting Permissions

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