Skip to content

Commit d09fc8f

Browse files
authored
[compiler-rt][builtins] Fix -Werror build problem (#100312)
GCC-14.1.1 emit an error due to uninitialized variables x86.c:303:17: error: ‘EAX’ may be used uninitialized [-Werror=maybe-uninitialized] x86.c:970:35: error: ‘MaxLevel’ may be used uninitialized [-Werror=maybe-uninitialized] x86.c:987:48: error: ‘MaxExtLevel’ may be used uninitialized [-Werror=maybe-uninitialized] It doesn't handle properly that these variables initialized indirectly in functions that takes pointers to them
1 parent fad17b4 commit d09fc8f

File tree

1 file changed

+3
-3
lines changed
  • compiler-rt/lib/builtins/cpu_model

1 file changed

+3
-3
lines changed

compiler-rt/lib/builtins/cpu_model/x86.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ static void getAvailableFeatures(unsigned ECX, unsigned EDX, unsigned MaxLeaf,
965965
if (HasLeaf7Subleaf1 && ((EDX >> 21) & 1))
966966
setFeature(FEATURE_APXF);
967967

968-
unsigned MaxLevel;
968+
unsigned MaxLevel = 0;
969969
getX86CpuIDAndInfo(0, &MaxLevel, &EBX, &ECX, &EDX);
970970
bool HasLeafD = MaxLevel >= 0xd &&
971971
!getX86CpuIDAndInfoEx(0xd, 0x1, &EAX, &EBX, &ECX, &EDX);
@@ -981,7 +981,7 @@ static void getAvailableFeatures(unsigned ECX, unsigned EDX, unsigned MaxLeaf,
981981
if (HasLeaf7Subleaf1 && ((EDX >> 19) & 1) && HasLeaf24 && ((EBX >> 18) & 1))
982982
setFeature(FEATURE_AVX10_1_512);
983983

984-
unsigned MaxExtLevel;
984+
unsigned MaxExtLevel = 0;
985985
getX86CpuIDAndInfo(0x80000000, &MaxExtLevel, &EBX, &ECX, &EDX);
986986

987987
bool HasExtLeaf1 = MaxExtLevel >= 0x80000001 &&
@@ -1075,7 +1075,7 @@ unsigned __cpu_features2[(CPU_FEATURE_MAX - 1) / 32];
10751075
// needs to be called explicitly there.
10761076

10771077
int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) {
1078-
unsigned EAX, EBX, ECX, EDX;
1078+
unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
10791079
unsigned MaxLeaf = 5;
10801080
unsigned Vendor;
10811081
unsigned Model, Family;

0 commit comments

Comments
 (0)