Skip to content

Intentional use of negative value to represent max unsigned #6

@safocl

Description

@safocl

This code depends on the integer rank and returns true

if (AutoOffTimer == -1){

example:
https://godbolt.org/z/n7Tavjc6W

relevant rules:
https://eel.is/c++draft/expr.arith.conv#1.5
https://eel.is/c++draft/expr.eq#8

but this example always false:
https://godbolt.org/z/a6jhjae1E

The int type has a non-fixed size in bits (implementation dependent) (-1 is a literal of type int)

If the stdint.h header is available, the UINTN_MAX definition can be used (N is the bit size of the integer type).

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions