pulsar-client-cpp icon indicating copy to clipboard operation
pulsar-client-cpp copied to clipboard

[Bug] Build fails on 32-bit platforms: overflow in expression; result is -64771072 with type 'long'

Open yurivict opened this issue 1 year ago • 3 comments

Search before asking

  • [X] I searched in the issues and found nothing similar.

Version

3.6.0

Minimal reproduce step

build on 32-bit platform

What did you expect to see?

n/a

What did you see instead?

In file included from /wrkdirs/usr/ports/net-p2p/pulsar-client-cpp/work/pulsar-client-cpp-3.6.0/lib/ClientConfiguration.cc:22:
/wrkdirs/usr/ports/net-p2p/pulsar-client-cpp/work/pulsar-client-cpp-3.6.0/lib/ClientConfigurationImpl.h:33:65: error: overflow in expression; result is -64771072 with type 'long' [-Werror,-Winteger-overflow]
   33 |     std::chrono::nanoseconds operationTimeout{30L * 1000 * 1000 * 1000};
      |                                               ~~~~~~~~~~~~~~~~~~^~~~~~
/wrkdirs/usr/ports/net-p2p/pulsar-client-cpp/work/pulsar-client-cpp-3.6.0/lib/ClientConfigurationImpl.h:33:65: error: overflow in expression; result is -64771072 with type 'long' [-Werror,-Winteger-overflow]
   33 |     std::chrono::nanoseconds operationTimeout{30L * 1000 * 1000 * 1000};
      |                                               ~~~~~~~~~~~~~~~~~~^~~~~~
2 errors generated.

Anything else?

log

Are you willing to submit a PR?

  • [ ] I'm willing to submit a PR!

yurivict avatar Oct 06 '24 18:10 yurivict

build on 32-bit platform

@yurivict what hardware are you targeting?

lhotari avatar Oct 06 '24 19:10 lhotari

On FreeBSD we run 32 builds for i386 and arm7. i386 binaries can also run on 64-bit systems on FreeBSD and Linux. This isn't particularly practical, but this is done in part to catch bugs this these.

yurivict avatar Oct 06 '24 19:10 yurivict

I think we should not use long here because long is not portable. We should use unsigned long long or the types from stdint.h

BewareMyPower avatar Oct 11 '24 05:10 BewareMyPower