Skip to content

[WebAssembly][clang] Implicit conversion from 'unsigned long long' to 'double' changes value #167179

@penguin359

Description

@penguin359

While attempting to cross-compile a project to the target wasm32-unknown-emscripten, a warning followed by a crash was triggered by the following line of code:

double current_diff = 0xFFFFFFFFFFFFFFFFULL;

I understand that that value is not precisely representable as a double, hence the warning, but I am not sure why it would result in a crash. The full output is here:

  CC       cgminer-cgminer.o
clang-19: warning: -lpthread: 'linker' input unused [-Wunused-command-line-argument]
cgminer.c:582:23: warning: implicit conversion from 'unsigned long long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Wimplicit-const-int-float-conversion]
  582 | double current_diff = 0xFFFFFFFFFFFFFFFFULL;
      |        ~~~~~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~~
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /usr/bin/clang-19 -target wasm32-unknown-emscripten -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/usr/share/emscripten/cache/sysroot -DEMSCRIPTEN -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -DHAVE_CONFIG_H -I. -lpthread -fcommon -fno-strict-aliasing -I./compat/jansson-2.9/src -I./compat/jansson-2.9/src -I./compat/libusb-1.0/libusb -I./lib -I./lib -g3 -O2 -MT cgminer-cgminer.o -MD -MP -MF .deps/cgminer-cgminer.Tpo -c cgminer.c -o cgminer-cgminer.o
1.      <eof> parser at end of file
2.      Code generation
#0 0x00007f37ee0ad40f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xead40f)
#1 0x00007f37ee0ab119 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xeab119)
#2 0x00007f37edff4127 (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xdf4127)
#3 0x00007f37eca458d0 (/lib/x86_64-linux-gnu/libc.so.6+0x458d0)
#4 0x00007ffdbc43c220
clang-19: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 19.1.7 (3ubuntu1)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /usr/lib/llvm-19/bin
clang-19: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-19: note: diagnostic msg: /tmp/cgminer-d3d7e1.c
clang-19: note: diagnostic msg: /tmp/cgminer-d3d7e1.sh
clang-19: note: diagnostic msg:

********************

Metadata

Metadata

Assignees

No one assigned

    Labels

    clangClang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions