root icon indicating copy to clipboard operation
root copied to clipboard

RtypesCore.h does not have a signed character type

Open dan131riley opened this issue 1 year ago • 1 comments

Check duplicate issues.

  • [X] Checked for duplicates

Description

The Char_t typedef here:

https://github.com/root-project/root/blob/4cf09dc362036e22eaa687cd2566fabb6c8ed693/core/foundation/inc/RtypesCore.h#L37

is incorrect--a bare char is not guaranteed to be signed or unsigned.

char — type for character representation which can be most efficiently processed on the target system (has the same representation and alignment as either signed char or unsigned char, but is always a distinct type). Multibyte characters strings use this type to represent code units. For every value of type unsigned char in range [​0​, 255], converting the value to char and then back to unsigned char produces the original value.(since C++11) The signedness of char depends on the compiler and the target platform: the defaults for ARM and PowerPC are typically unsigned, the defaults for x86 and x64 are typically signed.

To actually guarantee to be a signed type, Char_t would have to be declared as signed char.

From another issue, it appears ROOT is moving away from Rtypes.h since the C++ standard has a evolved a more complete type system, so this may be a "who cares" issue...

Reproducer

n/a

ROOT version

latest

Installation method

n/a

Operating system

n/a

Additional context

No response

dan131riley avatar Jun 25 '24 12:06 dan131riley

Related:

https://github.com/root-project/root/issues/12208 https://github.com/root-project/root/issues/7565

ferdymercury avatar Jun 25 '24 12:06 ferdymercury