Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. WebAssembly error/bug ?! float unrepresentable in integer range
Forum Update on Monday, May 27th 2025

WebAssembly error/bug ?! float unrepresentable in integer range

Scheduled Pinned Locked Moved Qt for WebAssembly
3 Posts 2 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Edwin F.E Offline
    Edwin F.E Offline
    Edwin F.
    wrote on last edited by Edwin F.
    #1

    I compiled a Qt app to WebAssembly using Emscripten. When I try to run the app in the browser I am seeing this output in the console of my browser, also see screenshot below it:

    exception thrown: RuntimeError: float unrepresentable in integer range,RuntimeError: float unrepresentable in integer range
        at wasm-function[32513]:0xbdce98
        at wasm-function[16435]:0x616a2a
        at wasm-function[6759]:0x230344
        at wasm-function[6760]:0x234104
        at wasm-function[16517]:0x6234ff
        at wasm-function[16221]:0x5fd749
        at wasm-function[10938]:0x3dfbe5
        at wasm-function[16137]:0x5efd48
        at wasm-function[10936]:0x3dd99c
        at wasm-function[16136]:0x5ef0b6
    

    webassembly-error.png

    Searching on the web for help on this I found that apparently it has something to do with 'trapping' (see link)
    WebAssembly Trapping

    As suggested I added the argument to avoid this trapping bug

    -mnontrapping-fptoint
    

    The way I added the argument was adding in my .pro file this line:

    QMAKE_CXXFLAGS += -mno-nontrapping-fptoint
    

    So when I 'qmake' using wasm (~/Qt/5.13.2/wasm_32/bin/qmake .) I can see the generated Makefile does indeed have the flag I added:

    ...
    CXXFLAGS      = -pipe -mno-nontrapping-fptoint 
    ...
    

    and then when I make I can see from the command output the argument is being passed in to em++ but for some reason it is ignored and the error still occurs after compiling and trying the app again in the browser:

    $ make
    em++ -c -pipe -mno-nontrapping-fptoint 
    ...
    ...
    clang++: warning: argument unused during compilation: '-mno-nontrapping-fptoint' [-Wunused-command-line-argument]
    ...
    ...
    

    I am using this version of Emscripten (sdk-fastcomp-1.38.27-64bit) and Qt 5.13.2

    $ em++ --version
    emcc (Emscripten gcc/clang-like replacement) 1.38.27 (commit 8f2f5e3435f6d0978469406a344a57a0d558deb1)
    
    $ clang++ --version
    clang version 6.0.1  (emscripten 1.38.27 : 1.38.27)
    
    

    This is a 'show-stopper' bug and I'm not sure how I can continue on. Thanks for your help guys!

    1 Reply Last reply
    0
    • Edwin F.E Offline
      Edwin F.E Offline
      Edwin F.
      wrote on last edited by Edwin F.
      #2

      I was able to get around this WebAssembly bug and I will post my findings here for the next poor soul that goes through this ordeal...

      I got it to work by manually adding

      -s BINARYEN_TRAP_MODE=clamp
      

      in the Makefile after executing qmake, this is what it looked like in the Makefile:

      LINK          = em++
      LFLAGS        = -s BINARYEN_TRAP_MODE=clamp -s WASM=1 -s FULL_ES2=1 -s USE_WEBGL2=1 -s NO_EXIT_RUNTIME=0 -s ERROR_ON_UNDEFINED_SYMBOLS=1 --bind -O3 -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=64MB
      
      

      Played around a bit and found out I can achieve the same without having to add manually each time to the Makefile by adding in the .pro file the following Qmake Lflag

      wasm {
      QMAKE_LFLAGS += -s BINARYEN_TRAP_MODE=clamp
      }
      
      

      Shout out to @lorn-potter I know you would be interested in this solution probably!

      1 Reply Last reply
      0
      • lorn.potterL Offline
        lorn.potterL Offline
        lorn.potter
        wrote on last edited by lorn.potter
        #3

        BINARYEN_TRAP_MODE=clamp has been part of Qt WebAssembly since before is was integrated into Qt proper.
        Look at: mkspecs/wasm-emscripten/qmake.conf

        It is not needed for WASM_OBJECT_FILES, which is now the default, so it was removed in the 5.15 series.

        There was a typo (a missing + in +=) for a while that stopped it from actually being used

        Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
        Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved