Open mikkelfj opened 1 month ago
The different compilers frustratingly each find totally disjoint sets of unreachable blocks, attesting to just how unreliable these warnings are, but I raised this one from msvc to your attention because it definitely seemed both valid and a genuine bug. Looks a bit like a merge that went awry.
clang found a bunch of other unreachable blocks which seem genuinely unreachable but don't appear malign: the gen_panic
macro in src/compiler/codegen_c.h which internally assert
s and then exit
s, so any code after it in a basic block is unreachable.
Incidentally, gcc accepts the -Wunreachable-code
flag but it has no effect on the compiler's behaviour, only being accepted for reasons of backwards compatibility according to their doc.
There is a some standard expression or attribute to indicate a function that does not (always) return. I don't recall, but if added, portable library would need to manage it for when compilers don't know about it.
There seems to be unreachable code in src/compiler/codegen_schema.c.
msvc looks at this block between the two
break
s and raises a warning. From a glance at the code, its analysis seems valid. I know this isn't strictly related to this PR, but I thought I would bring it to your attention as the code definitely looks strange to me.Originally posted by @amcn in https://github.com/dvidelabs/flatcc/issues/262#issuecomment-2335731813