GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
testsuite

Testsuite: Correctly initialize struct in divide-by-zero test.

Fixes the gcc.dg/analyzer/divide-by-zero-6.c test by ensuring the struct is fully initialized on all architectures.

This commit fixes a test case (gcc.dg/analyzer/divide-by-zero-6.c) that was failing intermittently due to incorrect struct initialization. The test used memset with sizeof (f) where f was a pointer, which only cleared part of the structure on 32-bit architectures, leading to uninitialized values instead of the intended division by zero. The fix uses sizeof (*f) to clear the entire structure.

In Details

The test gcc.dg/analyzer/divide-by-zero-6.c was using __builtin_memset (f, 0, sizeof (f)) to clear a struct, but f was a pointer. This meant that only part of the struct was being cleared on 32-bit targets. The change replaces sizeof (f) with sizeof (*f) to ensure the whole structure is cleared on all architectures.

For Context

Compiler test suites are designed to verify that the compiler correctly identifies and reports errors. This commit fixes a test case that was intended to detect division by zero errors. The test was failing because a structure was not being properly initialized, leading to a different error (use of an uninitialized value) on some systems. The fix ensures that the structure is fully initialized, allowing the test to correctly verify the division by zero detection.

Filed Under: testsuiteanalyzerdivide by zeroinitialization