Commit 0ffd056c for tesseract
commit 0ffd056cd029740f332bc048104dd339891c1b7e
Author: Stefan Weil <sw@weilnetz.de>
Date: Fri Nov 27 13:46:38 2026 +0100
Fix prototype styles mixed and automatic in a bit-field
PROTOTYPE stores its style in a bit-field of 2 bits. Since commit
6aac05e9 PROTOSTYLE is an enum class with the underlying type int,
so the bit-field is signed and holds mixed and automatic as -2 and
-1. With clang a switch statement did not match these two styles,
and with g++ a comparison with == did not.
Use an unsigned underlying type.
The training tools only use elliptical prototypes, so this had no
effect there. g++ reported it with -Wall (-Woverflow, -Wswitch).
Assisted-by: Claude Fable 5.2 (Anthropic)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
diff --git a/src/classify/cluster.h b/src/classify/cluster.h
index 90c18117..1c455b6d 100644
--- a/src/classify/cluster.h
+++ b/src/classify/cluster.h
@@ -50,7 +50,9 @@ struct CLUSTER {
};
using SAMPLE = CLUSTER; // can refer to as either sample or cluster
-enum class PROTOSTYLE {
+// The underlying type must be unsigned: PROTOTYPE stores the style in a
+// bit-field of 2 bits, which cannot hold mixed and automatic when it is signed.
+enum class PROTOSTYLE : unsigned {
spherical,
elliptical,
mixed,