root-project / root

The official repository for ROOT: analyzing, storing and visualizing big data, scientifically
https://root.cern
Other
2.64k stars 1.26k forks source link

RtypesCore.h does not have a signed character type #15927

Open dan131riley opened 2 months ago

dan131riley commented 2 months ago

Check duplicate issues.

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

ferdymercury commented 2 months ago

Related:

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