Skip to content

undefined behavior when computing ABS_FOR_PRINTING of LLONG_MIN #224

@eyalroz

Description

@eyalroz

When computing ABS_FOR_PRINTING(-9223372036854775808), we hit undefined behavior:

/home/eyalroz/src/mine/printf/test/../src/printf/printf.c:1418:35: runtime error: negation of 
-9223372036854775808 cannot be represented in type 'printf_signed_value_t' (aka 'long long');
cast to an unsigned type to negate this value to itself.

we need to change the ABS_FOR_PRINTING() logic to avoid undefined behavior... without changing "real" behavior and hopefully without complicating the code much.

Metadata

Metadata

Assignees

Labels

resolved-on-developA changeset fixing this issue has been commiutted to the development branchtask

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions