Skip to content

Conversation

@rigtorp
Copy link
Contributor

@rigtorp rigtorp commented Aug 15, 2016

Due to a quirk in C++ int64 minimum value can not be encoded as
literal. You need to use INT64_MIN constant.

Due to a quirk in C++ int64 minimum value can not be encoded as
literal. You need to use INT64_MIN constant.
@rigtorp
Copy link
Contributor Author

rigtorp commented Aug 16, 2016

@tmontgomery This schema ftp://ftp.moex.com/pub/FORTS/TWIME/doc/wire.xml generates code that causes warnings due to "-9223372036854775808L" literal overflowing the int64. This is a fix for that.

@rigtorp
Copy link
Contributor Author

rigtorp commented Aug 16, 2016

This is what GCC 6.1 will give you:

1 : warning: integer constant is so large that it is unsigned
int64_t i = -9223372036854775808L;

@tmontgomery
Copy link
Contributor

@rigtorp
Copy link
Contributor Author

rigtorp commented Aug 16, 2016

That's fine. INT64_MIN is defined to equal -9223372036854775808. It's just a quirk with the way C/C++ is parsed that causes this.

@rigtorp
Copy link
Contributor Author

rigtorp commented Aug 18, 2016

@tmontgomery Just so you understand what's going on here:

This compiles:

#include <cstdint>
static_assert(INT64_MIN == -9223372036854775808L);

With GCC 6.1 output:

2 : warning: integer constant is so large that it is unsigned
static_assert(INT64_MIN == -9223372036854775808L);
^~~~~~~~~~~~~~~~~~~~
Compiled ok

With clang 3.8 output:

2 : warning: integer literal is too large to be represented in a signed integer type, interpreting as unsigned [-Wimplicitly-unsigned-literal]
static_assert(INT64_MIN == -9223372036854775808L,"");
^
1 warning generated.
Compiled ok

INT64_MIN is defined as:

# define INT64_MIN              (-__INT64_C(9223372036854775807)-1)

Conclusion:
INT64_MIN is equal to -9223372036854775808, which is the smallest 64bit signed integer.
INT64_MIN is defined with a trick to avoid the above warning.

It would be great to fix this warning.

@tmontgomery tmontgomery merged commit e9018bd into aeron-io:master Aug 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants