Pelles C > FAQ
Unreachable code
(1/1)
Grincheux:
Could you make a thread on that subject.
Because I don't understand anything.
I have tested many compilers and Pelle is the only one that emits that kind of warning. I suppose it is is a good thing. But and can I correct this warning in my code.
Thank You
frankie:
Unreachable, or dead, code is that code that will never be executed, and for this reason will not be emitted by the compiler.
These parts are normally generated when a conditional execution resolves to a constant comparison that allows the compiler to evaluate that the code will never execute during compilation. I.e.
--- Code: --- const a=2; //This is a constant value
...
if (a ==10) //This condition will never be true. The code will be removed
{
printf("Dead code. Will never be executed!\");
}
--- End code ---
Another example is when there is code after a return statement:
--- Code: ---void foo(void)
{
printf("foo()\n");
return;
printf("Dead code. Will never be executed!\");
}
--- End code ---
The warn is very useful if you put the code there by mistake.
Grincheux:
Ok Frankie, I had understood this but this is not always the case.
Specially this one :
--- Code: ---uint64_t crc64speed(uint64_t crc, const void *s, const uint64_t l)
{
/* Quickly check if CRC table is initialized to little endian correctly. */
#ifndef CRC64SPEED_DUAL
check_init(crc64_table, LITTLE1);
#else
check_init(crc64_table_little, LITTLE1);
#endif
return crcspeed64little(dual ? crc64_table_little : crc64_table, crc,(void *)s, l);
}
--- End code ---
--- Quote ---return crcspeed64little(dual ? crc64_table_little : crc64_table, crc,(void *)s, l);
--- End quote ---
https://github.com/mattsta/crcspeed
https://github.com/mattsta/crc64-compare
https://matt.sh/redis-crcspeed
frankie:
What is the exact warning text?
On which line? In the following line?
--- Code: ---return crcspeed64little(dual ? crc64_table_little : crc64_table, crc,(void *)s, l);
--- End code ---
It could also be a bug...
Navigation
[0] Message Index
Go to full version