Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implicit int-float conversion changes values #795

Open
claudeha opened this issue Nov 26, 2019 · 1 comment
Open

implicit int-float conversion changes values #795

claudeha opened this issue Nov 26, 2019 · 1 comment
Labels

Comments

@claudeha
Copy link
Contributor

@claudeha claudeha commented Nov 26, 2019

Ran into this updating my pure-data/libpd/emscripten fork to pd-0.50-2. These might be real bugs. I'm not sure. (I will try to figure out how to disable -Werror so that this doesn't block me.)

emscripten@eiskaffee:~/opt/src/libpd/build$ emmake make -k
make: ['make', '-k']
Scanning dependencies of target libpd_static
[  1%] Building C object CMakeFiles/libpd_static.dir/pure-data/src/d_soundfile.c.o
/home/emscripten/opt/src/libpd/pure-data/src/d_soundfile.c:1307:52: error: implicit conversion from 'long' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion]
                ((maxsize = (argv[1].a_w.w_float > LONG_MAX ?
                                                 ~ ^~~~~~~~
/home/emscripten/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten/bits/limits.h:7:19: note: expanded from macro 'LONG_MAX'
#define LONG_MAX  0x7fffffffL
                  ^~~~~~~~~~~
1 error generated.
shared:ERROR: '/home/emscripten/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=39 -D__EMSCRIPTEN_tiny__=3 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/libcxx -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/lib/libcxxabi/include -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/compat -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/libc -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/local/include -DHAVE_LIBDL -DHAVE_UNISTD_H=1 -DLIBPD_EXTRA=1 -DPD=1 -DPD_INTERNAL -DUSEAPI_DUMMY=1 -I/home/emscripten/opt/src/libpd/libpd_wrapper -I/home/emscripten/opt/src/libpd/pure-data/src -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Werror -Wno-#warnings -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Werror -Wno-#warnings -ffast-math -funroll-loops -fomit-frame-pointer -O3 -fPIC -c -DEMSCRIPTEN /home/emscripten/opt/src/libpd/pure-data/src/d_soundfile.c -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/SDL -c -o CMakeFiles/libpd_static.dir/pure-data/src/d_soundfile.c.o -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr' failed (1)
make[2]: *** [CMakeFiles/libpd_static.dir/build.make:246: CMakeFiles/libpd_static.dir/pure-data/src/d_soundfile.c.o] Error 1
[  1%] Building C object CMakeFiles/libpd_static.dir/pure-data/src/g_array.c.o
/home/emscripten/opt/src/libpd/pure-data/src/g_array.c:619:18: error: implicit conversion from 'int' to 't_float' (aka 'float') changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion]
    t_float x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff;
            ~~   ^~~~~~~~~~
/home/emscripten/opt/src/libpd/pure-data/src/g_array.c:619:35: error: implicit conversion from 'int' to 't_float' (aka 'float') changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion]
    t_float x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff;
                             ~~   ^~~~~~~~~~
/home/emscripten/opt/src/libpd/pure-data/src/g_array.c:619:52: error: implicit conversion from 'int' to 't_float' (aka 'float') changes value from -2147483647 to -2147483648 [-Werror,-Wimplicit-int-float-conversion]
    t_float x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff;
                                              ~~   ^~~~~~~~~~~
/home/emscripten/opt/src/libpd/pure-data/src/g_array.c:619:70: error: implicit conversion from 'int' to 't_float' (aka 'float') changes value from -2147483647 to -2147483648 [-Werror,-Wimplicit-int-float-conversion]
    t_float x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff;
                                                                ~~   ^~~~~~~~~~~
4 errors generated.
shared:ERROR: '/home/emscripten/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=39 -D__EMSCRIPTEN_tiny__=3 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/libcxx -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/lib/libcxxabi/include -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/compat -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/libc -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/local/include -DHAVE_LIBDL -DHAVE_UNISTD_H=1 -DLIBPD_EXTRA=1 -DPD=1 -DPD_INTERNAL -DUSEAPI_DUMMY=1 -I/home/emscripten/opt/src/libpd/libpd_wrapper -I/home/emscripten/opt/src/libpd/pure-data/src -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Werror -Wno-#warnings -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Werror -Wno-#warnings -ffast-math -funroll-loops -fomit-frame-pointer -O3 -fPIC -c -DEMSCRIPTEN /home/emscripten/opt/src/libpd/pure-data/src/g_array.c -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/SDL -c -o CMakeFiles/libpd_static.dir/pure-data/src/g_array.c.o -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr' failed (1)
make[2]: *** [CMakeFiles/libpd_static.dir/build.make:288: CMakeFiles/libpd_static.dir/pure-data/src/g_array.c.o] Error 1
[  1%] Building C object CMakeFiles/libpd_static.dir/pure-data/src/x_text.c.o
/home/emscripten/opt/src/libpd/pure-data/src/x_text.c:1504:28: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion]
    x->x_onset = (onset >= 0x7fffffff ? 0x7ffffff : (onset < 0 ? 0 : onset));
                        ~~ ^~~~~~~~~~
/home/emscripten/opt/src/libpd/pure-data/src/x_text.c:1505:28: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion]
    x->x_range = (range >= 0x7fffffff ? 0x7ffffff : (range < 0 ? 0 : range));
                        ~~ ^~~~~~~~~~
2 errors generated.
shared:ERROR: '/home/emscripten/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=39 -D__EMSCRIPTEN_tiny__=3 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/libcxx -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/lib/libcxxabi/include -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/compat -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/libc -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/local/include -DHAVE_LIBDL -DHAVE_UNISTD_H=1 -DLIBPD_EXTRA=1 -DPD=1 -DPD_INTERNAL -DUSEAPI_DUMMY=1 -I/home/emscripten/opt/src/libpd/libpd_wrapper -I/home/emscripten/opt/src/libpd/pure-data/src -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Werror -Wno-#warnings -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Werror -Wno-#warnings -ffast-math -funroll-loops -fomit-frame-pointer -O3 -fPIC -c -DEMSCRIPTEN /home/emscripten/opt/src/libpd/pure-data/src/x_text.c -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/SDL -c -o CMakeFiles/libpd_static.dir/pure-data/src/x_text.c.o -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr' failed (1)
make[2]: *** [CMakeFiles/libpd_static.dir/build.make:1016: CMakeFiles/libpd_static.dir/pure-data/src/x_text.c.o] Error 1
make[2]: Target 'CMakeFiles/libpd_static.dir/build' not remade because of errors.
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/libpd_static.dir/all] Error 2
Scanning dependencies of target libpd
[  2%] Building C object CMakeFiles/libpd.dir/pure-data/src/d_soundfile.c.o
/home/emscripten/opt/src/libpd/pure-data/src/d_soundfile.c:1307:52: error: implicit conversion from 'long' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion]
                ((maxsize = (argv[1].a_w.w_float > LONG_MAX ?
                                                 ~ ^~~~~~~~
/home/emscripten/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten/bits/limits.h:7:19: note: expanded from macro 'LONG_MAX'
#define LONG_MAX  0x7fffffffL
                  ^~~~~~~~~~~
1 error generated.
shared:ERROR: '/home/emscripten/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=39 -D__EMSCRIPTEN_tiny__=3 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/libcxx -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/lib/libcxxabi/include -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/compat -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/libc -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/local/include -DHAVE_LIBDL -DHAVE_UNISTD_H=1 -DLIBPD_EXTRA=1 -DPD=1 -DPD_INTERNAL -DUSEAPI_DUMMY=1 -I/home/emscripten/opt/src/libpd/libpd_wrapper -I/home/emscripten/opt/src/libpd/pure-data/src -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Werror -Wno-#warnings -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Werror -Wno-#warnings -ffast-math -funroll-loops -fomit-frame-pointer -O3 -fPIC -c -DEMSCRIPTEN /home/emscripten/opt/src/libpd/pure-data/src/d_soundfile.c -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/SDL -c -o CMakeFiles/libpd.dir/pure-data/src/d_soundfile.c.o -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr' failed (1)
make[2]: *** [CMakeFiles/libpd.dir/build.make:246: CMakeFiles/libpd.dir/pure-data/src/d_soundfile.c.o] Error 1
[  2%] Building C object CMakeFiles/libpd.dir/pure-data/src/g_array.c.o
/home/emscripten/opt/src/libpd/pure-data/src/g_array.c:619:18: error: implicit conversion from 'int' to 't_float' (aka 'float') changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion]
    t_float x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff;
            ~~   ^~~~~~~~~~
/home/emscripten/opt/src/libpd/pure-data/src/g_array.c:619:35: error: implicit conversion from 'int' to 't_float' (aka 'float') changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion]
    t_float x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff;
                             ~~   ^~~~~~~~~~
/home/emscripten/opt/src/libpd/pure-data/src/g_array.c:619:52: error: implicit conversion from 'int' to 't_float' (aka 'float') changes value from -2147483647 to -2147483648 [-Werror,-Wimplicit-int-float-conversion]
    t_float x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff;
                                              ~~   ^~~~~~~~~~~
/home/emscripten/opt/src/libpd/pure-data/src/g_array.c:619:70: error: implicit conversion from 'int' to 't_float' (aka 'float') changes value from -2147483647 to -2147483648 [-Werror,-Wimplicit-int-float-conversion]
    t_float x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff;
                                                                ~~   ^~~~~~~~~~~
4 errors generated.
shared:ERROR: '/home/emscripten/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=39 -D__EMSCRIPTEN_tiny__=3 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/libcxx -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/lib/libcxxabi/include -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/compat -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/libc -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/local/include -DHAVE_LIBDL -DHAVE_UNISTD_H=1 -DLIBPD_EXTRA=1 -DPD=1 -DPD_INTERNAL -DUSEAPI_DUMMY=1 -I/home/emscripten/opt/src/libpd/libpd_wrapper -I/home/emscripten/opt/src/libpd/pure-data/src -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Werror -Wno-#warnings -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Werror -Wno-#warnings -ffast-math -funroll-loops -fomit-frame-pointer -O3 -fPIC -c -DEMSCRIPTEN /home/emscripten/opt/src/libpd/pure-data/src/g_array.c -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/SDL -c -o CMakeFiles/libpd.dir/pure-data/src/g_array.c.o -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr' failed (1)
make[2]: *** [CMakeFiles/libpd.dir/build.make:288: CMakeFiles/libpd.dir/pure-data/src/g_array.c.o] Error 1
[  2%] Building C object CMakeFiles/libpd.dir/pure-data/src/x_text.c.o
/home/emscripten/opt/src/libpd/pure-data/src/x_text.c:1504:28: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion]
    x->x_onset = (onset >= 0x7fffffff ? 0x7ffffff : (onset < 0 ? 0 : onset));
                        ~~ ^~~~~~~~~~
/home/emscripten/opt/src/libpd/pure-data/src/x_text.c:1505:28: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion]
    x->x_range = (range >= 0x7fffffff ? 0x7ffffff : (range < 0 ? 0 : range));
                        ~~ ^~~~~~~~~~
2 errors generated.
shared:ERROR: '/home/emscripten/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=39 -D__EMSCRIPTEN_tiny__=3 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/libcxx -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/lib/libcxxabi/include -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/compat -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/libc -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/local/include -DHAVE_LIBDL -DHAVE_UNISTD_H=1 -DLIBPD_EXTRA=1 -DPD=1 -DPD_INTERNAL -DUSEAPI_DUMMY=1 -I/home/emscripten/opt/src/libpd/libpd_wrapper -I/home/emscripten/opt/src/libpd/pure-data/src -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Werror -Wno-#warnings -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Werror -Wno-#warnings -ffast-math -funroll-loops -fomit-frame-pointer -O3 -fPIC -c -DEMSCRIPTEN /home/emscripten/opt/src/libpd/pure-data/src/x_text.c -Xclang -isystem/home/emscripten/emsdk/upstream/emscripten/system/include/SDL -c -o CMakeFiles/libpd.dir/pure-data/src/x_text.c.o -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr' failed (1)
make[2]: *** [CMakeFiles/libpd.dir/build.make:1016: CMakeFiles/libpd.dir/pure-data/src/x_text.c.o] Error 1
make[2]: Target 'CMakeFiles/libpd.dir/build' not remade because of errors.
make[1]: *** [CMakeFiles/Makefile2:110: CMakeFiles/libpd.dir/all] Error 2
make[1]: Target 'all' not remade because of errors.
make: *** [Makefile:84: all] Error 2
make: Target 'default_target' not remade because of errors.
emscripten@eiskaffee:~/opt/src/libpd/build$ 
@Spacechild1

This comment has been minimized.

Copy link
Contributor

@Spacechild1 Spacechild1 commented Nov 26, 2019

Yes, LONG_MAX can't be accurately represented by 32bit floats, so we should add some casts here. I don't think it leads to actual bugs, but it's definitely wrong code.

@umlaeute umlaeute added the bug/fix label Dec 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.