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

Ubuntu 16 i686: case value cannot be narrowed to type '__fsword_t' (aka 'int') ; result of comparison, 'uintptr_t' (aka 'unsigned int') is always false #5663

Open
advancedwebdeveloper opened this issue Nov 9, 2020 · 4 comments

Comments

@advancedwebdeveloper
Copy link

Hi.

Build failed on

$ uname -a
Linux mylaptop 4.15.0-122-generic #124~16.04.1-Ubuntu SMP Thu Oct 15 16:14:02 UTC 2020 i686 i686 i686 GNU/Linux

with

$ clang-11 --version
Ubuntu clang version 11.0.0-++20200721055954+cebd637c886-1exp120200721161335.13
Target: i686-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

and

$ cmake --version
cmake version 3.19.0-rc2

.
My generator is configured for

$ ninja --version
1.10.0.git.kitware.jobserver-1

So I got these errors:

$ ninja
[2/431] Building CXX object tools/tracegen/CMakeFiles/trace.dir/Port.cpp.o
FAILED: tools/tracegen/CMakeFiles/trace.dir/Port.cpp.o
/usr/bin/clang++-11 -DJ9X86 -DLINUX -D_FILE_OFFSET_BITS=64 -D_X86_ -pthread -fno-strict-aliasing -m32 -msse2 -std=c++0x -fPIC -Werror -Wall -MD -MT tools/tracegen/CMakeFiles/trace.dir/Port.cpp.o -MF tools/tracegen/CMakeFiles/trace.dir/Port.cpp.o.d -o tools/tracegen/CMakeFiles/trace.dir/Port.cpp.o -c /home/oceanfish81/omr/tools/tracegen/Port.cpp
/home/oceanfish81/omr/tools/tracegen/Port.cpp:691:7: error: case value evaluates to 4283649346, which cannot be narrowed to type '__fsword_t' (aka 'int') [-Wc++11-narrowing]
case 0xFF534D42: /* CIFS_MAGIC_NUMBER */
^
1 error generated.
ninja: build stopped: subcommand failed.

$ ninja
[76/408] Building C object port/CMakeFiles/omrport_obj.dir/linux/omrvmem.c.o
FAILED: port/CMakeFiles/omrport_obj.dir/linux/omrvmem.c.o
/usr/bin/clang-11 -DJ9X86 -DLINUX -DOMRPORT_LIBRARY_DEFINE -D_FILE_OFFSET_BITS=64 -D_X86_ -I/home/oceanfish81/omr/port -Iport -I/home/oceanfish81/omr/include_core -I. -I/home/oceanfish81/omr/port/linux386 -I/home/oceanfish81/omr/port/linux -I/home/oceanfish81/omr/port/unix -I/home/oceanfish81/omr/port/unix_include -I/home/oceanfish81/omr/port/common -I/home/oceanfish81/omr/port/include -I/home/oceanfish81/omr/port/../nls -pthread -fno-strict-aliasing -m32 -msse2 -fPIC -Werror -Wall -MD -MT port/CMakeFiles/omrport_obj.dir/linux/omrvmem.c.o -MF port/CMakeFiles/omrport_obj.dir/linux/omrvmem.c.o.d -o port/CMakeFiles/omrport_obj.dir/linux/omrvmem.c.o -c /home/oceanfish81/omr/port/linux/omrvmem.c
/home/oceanfish81/omr/port/linux/omrvmem.c:474:23: error: result of comparison of constant 18446744073709551615 with expression of type 'uintptr_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if ((ULLONG_MAX == start) && (ERANGE == errno)) {
~~~~~~~~~~ ^ ~~~~~
/home/oceanfish81/omr/port/linux/omrvmem.c:487:23: error: result of comparison of constant 18446744073709551615 with expression of type 'uintptr_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if ((ULLONG_MAX == end) && (ERANGE == errno)) {
~~~~~~~~~~ ^ ~~~
2 errors generated.
[91/408] Building CXX object gc/CMakeFiles/omrgc.dir/base/HeapMap.cpp.o
ninja: build stopped: subcommand failed.

@mstoodle
Copy link
Contributor

Apologies for the late response here @advancedwebdeveloper : most of the folks working on OMR don't do much with 32-bit systems and we seem to have lost most of our active port library contributors :( .

32-bit builds using the recommended (ancient) compilers seem to work just fine (now that we've removed a misconfigured machine from the build list). But not so much on the system/build compiler you're using, apparently.

The first problem is because the file system type for CIFS_MAGIC_NUMBER (0xFF534D42) is an unsigned value but the field of the struct that holds the type is a signed type on your system, for whatever reason. The type of that field is an internal type, so I don't want to use it. The best solutions I could find for this problem are either to cast the field to an unsigned int or to cast the constant to a signed int. The fix I'll propose is to cast the constant to signed int as having the least impact.

The second problem is just a type mismatch. On your platform uintptr_t doesn't evaluate to unsigned long long. The values need to be cast to ADDRESS which, on 32-bit, needs to go through uintptr_t anyway, but for the comparison we should be using the raw unsigned long long value returned by strtoull().

I'll put a pull request together and see how people feel about it. I've confirmed that these two changes build just fine inside a 32-bit ubuntu docker container, but since I could not reproduce the original problem it would be helpful if @advancedwebdeveloper could help us validate the patch to make sure we've caught the problems.

@mstoodle
Copy link
Contributor

@advancedwebdeveloper would you please provide the cmake command line you've used, just for reference?

@davidjmccann
Copy link
Contributor

@mstoodle I can hit the warnings highlighted by this issue and can confirm that the two changes you propose gets rid of the warnings.

@mstoodle
Copy link
Contributor

mstoodle commented Mar 7, 2022

Thanks @davidjmccann! I'll refresh the pull request for cleaner history and then remove the WIP so it can be merged .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants