https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118415
Bug ID: 118415
Summary: [15 Regression] crc optimization uses user accessible
symbols
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: jakub at gcc dot gnu.org
Target Milestone: ---
unsigned char crc_table_for_crc_8_polynomial_0x7[2] = { 0xff, 0xff };
static unsigned char
foo (unsigned char byte, unsigned char crc)
{
unsigned int i;
crc ^= byte;
for (i = 0; i < 8; i++)
crc = (crc << 1) ^ ((crc >> 7) ? 0x07 : 0);
return crc;
}
int
main ()
{
volatile unsigned char byte = 1;
volatile unsigned char crc = 0;
crc = foo (byte, crc);
if (crc != 7)
__builtin_abort ();
}
is miscompiled starting with the introduction of the CRC optimization.
Using user accessible symbols should be only the last resort, I think in
any case the name should start with double underscore and have at least one of
the underscores replaced with . or $ if the target supports dot
(NO_DOT_IN_LABEL, NO_DOLLAR_IN_LABEL).
I think the symbol should be also hidden whenever target supports that, it is
fine to merge those across TUs within one executable or shared library, but the
optimization shouldn't add to the list of exported symbols.