8000 Build fails on 32-bit systems: error: result of comparison of constant 1103806595072 with expression of type 'size_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare] · Issue #88 · mctools/mcpl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Build fails on 32-bit systems: error: result of comparison of constant 1103806595072 with expression of type 'size_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare] #88

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

Closed
yurivict opened this issue May 9, 2025 · 3 comments · Fixed by #89

Comments

@yurivict
Copy link
yurivict commented May 9, 2025
/wrkdirs/usr/ports/science/mcpl/work/mcpl-2.0.0/mcpl_core/src/mcpl.c
/wrkdirs/usr/ports/science/mcpl/work/mcpl-2.0.0/mcpl_core/src/mcpl.c:3225:3: error: 'mcpl_fail_at_line_3225' declared as an array with a negative size
 3225 |   MCPL_STATIC_ASSERT( sizeof(size_t) >= sizeof(uint64_t) );
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/science/mcpl/work/mcpl-2.0.0/mcpl_core/src/mcpl.c:108:37: note: expanded from macro 'MCPL_STATIC_ASSERT'
  108 | #define MCPL_STATIC_ASSERT(expr)    MCPL_STATIC_ASSERT2(expr,__LINE__)
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/science/mcpl/work/mcpl-2.0.0/mcpl_core/src/mcpl.c:107:37: note: expanded from macro 'MCPL_STATIC_ASSERT2'
  107 | #define MCPL_STATIC_ASSERT2(expr,x) MCPL_STATIC_ASSERT3(expr,x)
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/science/mcpl/work/mcpl-2.0.0/mcpl_core/src/mcpl.c:106:37: note: expanded from macro 'MCPL_STATIC_ASSERT3'
  106 | #define MCPL_STATIC_ASSERT3(expr,x) MCPL_STATIC_ASSERT0(expr,fail_at_line_##x)
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/science/mcpl/work/mcpl-2.0.0/mcpl_core/src/mcpl.c:105:65: note: expanded from macro 'MCPL_STATIC_ASSERT0'
  105 | #define MCPL_STATIC_ASSERT0(COND,MSG) { typedef char mcpl_##MSG[(COND)?1:-1]; mcpl_##MSG dummy; (void)dummy; }
      |                                                                 ^~~~~~~~~~~
/wrkdirs/usr/ports/science/mcpl/work/mcpl-2.0.0/mcpl_core/src/mcpl.c:3238:23: error: result of comparison of constant 1103806595072 with expression of type 'size_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
 3238 |     if ( out.capacity >= 1103806595072 )
      |          ~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~
2 errors generated.

If the project doesn't support 32-bit systems then cmake should fail with an appropriate message.

Version: 2.0.0
clang-19
FreeBSD 14.2

@tkittel
Copy link
Member
tkittel commented May 12, 2025

Indeed, we do not support 32 bit systems, since we for consistency want to support files >4GB on all systems. The decision was made easier since we have no knowledge of any of our users actually needing 32bit systems.

But you are right, CMake should mention this with a much clearer warning. The C99 compatible static_assert messages we use are a bit obscure, since they do not support an actual messages.

@yurivict
Copy link
Author

Here is how cmake can detect bitness:

if(CMAKE_SIZEOF_VOID_P EQUAL 4)
  message(STATUS "Building for 32-bit platform")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
  message(STATUS "Building for 64-bit platform")
else()
  message(FATAL_ERROR "Unknown platform bitness")
endif()

@tkittel tkittel self-assigned this May 13, 2025
@tkittel tkittel linked a pull request May 13, 2025 that will close this issue
@tkittel
Copy link
Member
tkittel commented May 20, 2025

Fixed in release 2.1.0.

@tkittel tkittel closed this as completed May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0