From 3c0c882726f5c66f931eebafb95c64bbfd79a0a3 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Tue, 12 Aug 2025 10:37:43 +0200 Subject: [PATCH 1/4] [nfc][core] document that char is not guaranteed to be signed Fixes https://github.com/root-project/root/issues/15927 --- core/foundation/inc/RtypesCore.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/foundation/inc/RtypesCore.h b/core/foundation/inc/RtypesCore.h index 78e9c84ccd2dc..00a44bfced4d0 100644 --- a/core/foundation/inc/RtypesCore.h +++ b/core/foundation/inc/RtypesCore.h @@ -48,7 +48,7 @@ class TRootIOCtor; //---- types ------------------------------------------------------------------- -typedef char Char_t; ///< Signed Character 1 byte (char) \deprecated Consider replacing with `char` or `std::int8_t` +typedef char Char_t; ///< Character 1 byte (char) \warning Can be signed (most common) or unsigned depending on platform and compiler flags. \deprecated Consider replacing with `char`, `signed char` or `std::int8_t` typedef unsigned char UChar_t; ///< Unsigned Character 1 byte (unsigned char) \deprecated Consider replacing with `unsigned char` or `std::uint8_t` typedef short Short_t; ///< Signed Short integer 2 bytes (short) \deprecated Consider replacing with `short` or `std::int16_t` typedef unsigned short UShort_t; ///< Unsigned Short integer 2 bytes (unsigned short) \deprecated Consider replacing with `unsigned short` or `std::uint16_t` From 7ad353b336d1f3d36f0434c5287d09d80c8b8691 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Tue, 12 Aug 2025 10:41:51 +0200 Subject: [PATCH 2/4] [nfc][tree] mention caveat of Char_t in docu --- tree/tree/src/TTree.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tree/tree/src/TTree.cxx b/tree/tree/src/TTree.cxx index fb37306f836c4..e45e7866a3277 100644 --- a/tree/tree/src/TTree.cxx +++ b/tree/tree/src/TTree.cxx @@ -93,7 +93,7 @@ It is strongly recommended to persistify those as objects rather than lists of l assumed of type F by default. The list of currently supported types is given below: - `C` : a character string terminated by the 0 character - - `B` : an 8 bit signed integer (`Char_t`); Treated as a character when in an array. + - `B` : an 8 bit signed integer (`Char_t`); Might be unsigned in special platforms or depending on compiler flags; Treated as a character when in an array. - `b` : an 8 bit unsigned integer (`UChar_t`) - `S` : a 16 bit signed integer (`Short_t`) - `s` : a 16 bit unsigned integer (`UShort_t`) @@ -1971,7 +1971,7 @@ Int_t TTree::Branch(const char* foldername, Int_t bufsize /* = 32000 */, Int_t s /// variable. If the first variable does not have a type, it is assumed /// of type F by default. The list of currently supported types is given below: /// - `C` : a character string terminated by the 0 character -/// - `B` : an 8 bit signed integer (`Char_t`); Treated as a character when in an array. +/// - `B` : an 8 bit signed integer (`Char_t`); ; Might be unsigned in special platforms or depending on compiler flags; Treated as a character when in an array. /// - `b` : an 8 bit unsigned integer (`UChar_t`) /// - `S` : a 16 bit signed integer (`Short_t`) /// - `s` : a 16 bit unsigned integer (`UShort_t`) From 21dacec2d2227caf75cf5c4127c6bc4fb77a5828 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Tue, 12 Aug 2025 10:46:48 +0200 Subject: [PATCH 3/4] [nfc][tree] clarify --- tree/tree/src/TTree.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tree/tree/src/TTree.cxx b/tree/tree/src/TTree.cxx index e45e7866a3277..89d153df711aa 100644 --- a/tree/tree/src/TTree.cxx +++ b/tree/tree/src/TTree.cxx @@ -93,7 +93,7 @@ It is strongly recommended to persistify those as objects rather than lists of l assumed of type F by default. The list of currently supported types is given below: - `C` : a character string terminated by the 0 character - - `B` : an 8 bit signed integer (`Char_t`); Might be unsigned in special platforms or depending on compiler flags; Treated as a character when in an array. + - `B` : an 8 bit integer (`Char_t`); Mostly signed, might be unsigned in special platforms or depending on compiler flags; Treated as a character when in an array. - `b` : an 8 bit unsigned integer (`UChar_t`) - `S` : a 16 bit signed integer (`Short_t`) - `s` : a 16 bit unsigned integer (`UShort_t`) @@ -1971,7 +1971,7 @@ Int_t TTree::Branch(const char* foldername, Int_t bufsize /* = 32000 */, Int_t s /// variable. If the first variable does not have a type, it is assumed /// of type F by default. The list of currently supported types is given below: /// - `C` : a character string terminated by the 0 character -/// - `B` : an 8 bit signed integer (`Char_t`); ; Might be unsigned in special platforms or depending on compiler flags; Treated as a character when in an array. +/// - `B` : an 8 bit integer (`Char_t`); Mostly signed, might be unsigned in special platforms or depending on compiler flags; Treated as a character when in an array. /// - `b` : an 8 bit unsigned integer (`UChar_t`) /// - `S` : a 16 bit signed integer (`Short_t`) /// - `s` : a 16 bit unsigned integer (`UShort_t`) From 65a4f6a181d095751d975fd47b4ae5fd2adc3e2f Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Tue, 12 Aug 2025 11:03:31 +0200 Subject: [PATCH 4/4] [nfc][tree] mention that it's not equivalent to int8_t Fixes https://github.com/root-project/root/issues/7565 --- tree/tree/src/TTree.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tree/tree/src/TTree.cxx b/tree/tree/src/TTree.cxx index 89d153df711aa..150589705ffa3 100644 --- a/tree/tree/src/TTree.cxx +++ b/tree/tree/src/TTree.cxx @@ -93,7 +93,7 @@ It is strongly recommended to persistify those as objects rather than lists of l assumed of type F by default. The list of currently supported types is given below: - `C` : a character string terminated by the 0 character - - `B` : an 8 bit integer (`Char_t`); Mostly signed, might be unsigned in special platforms or depending on compiler flags; Treated as a character when in an array. + - `B` : an 8 bit integer (`Char_t`); Mostly signed, might be unsigned in special platforms or depending on compiler flags, thus do not use std::int8_t as underlying variable since they are not equivalent; Treated as a character when in an array. - `b` : an 8 bit unsigned integer (`UChar_t`) - `S` : a 16 bit signed integer (`Short_t`) - `s` : a 16 bit unsigned integer (`UShort_t`) @@ -1971,7 +1971,7 @@ Int_t TTree::Branch(const char* foldername, Int_t bufsize /* = 32000 */, Int_t s /// variable. If the first variable does not have a type, it is assumed /// of type F by default. The list of currently supported types is given below: /// - `C` : a character string terminated by the 0 character -/// - `B` : an 8 bit integer (`Char_t`); Mostly signed, might be unsigned in special platforms or depending on compiler flags; Treated as a character when in an array. +/// - `B` : an 8 bit integer (`Char_t`); Mostly signed, might be unsigned in special platforms or depending on compiler flags, thus do not use std::int8_t as underlying variable since they are not equivalent; Treated as a character when in an array. /// - `b` : an 8 bit unsigned integer (`UChar_t`) /// - `S` : a 16 bit signed integer (`Short_t`) /// - `s` : a 16 bit unsigned integer (`UShort_t`)