Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unintended dead code in binary schema generation #295

Open
mikkelfj opened this issue Sep 11, 2024 · 2 comments
Open

Unintended dead code in binary schema generation #295

mikkelfj opened this issue Sep 11, 2024 · 2 comments
Labels

Comments

@mikkelfj
Copy link
Contributor

mikkelfj commented Sep 11, 2024

There seems to be unreachable code in src/compiler/codegen_schema.c.

msvc looks at this block between the two breaks 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 #262 (comment)

@mikkelfj mikkelfj added the bug label Sep 11, 2024
@amcn
Copy link

amcn commented Sep 11, 2024

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 asserts and then exits, 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.

@mikkelfj
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants