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

Fix build with GCC. #73

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

PiotrSikora
Copy link

Signed-off-by: Piotr Sikora [email protected]

Signed-off-by: Piotr Sikora <[email protected]>
@PiotrSikora
Copy link
Author

cc @rossberg

@@ -605,6 +605,7 @@ auto ExternType::copy() const -> own<ExternType*> {
case EXTERN_GLOBAL: return global()->copy();
case EXTERN_TABLE: return table()->copy();
case EXTERN_MEMORY: return memory()->copy();
default: assert(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, wouldn't having a branch with no return trip up other compilers?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funnily enough, I've added all those asserts (with the exception of the one in src/wasm-v8.cc:2199, which I added for completeness) to silence the no return errors in GCC:

error: control reaches end of non-void function [-Werror=return-type]

so this works fine for both: clang and gcc, at least using default CFLAGS.

But now that you pointed this out, I realized that this will indeed break when building with -DNDEBUG (i.e. when assert() is omitted), but this is already the case in master, since the same pattern is used in a few other places, e.g. in src/wasm-bin.cc:220:

assert(false);

Perhaps all those assert(false) should be replaced with UNIMPLEMENTED()? What do you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, though I don't think we want to abuse UNIMPLEMENTED, but define a similar UNREACHABLE. Do you mind including that with this PR?

Copy link
Member

@rossberg rossberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long delay!

@@ -605,6 +605,7 @@ auto ExternType::copy() const -> own<ExternType*> {
case EXTERN_GLOBAL: return global()->copy();
case EXTERN_TABLE: return table()->copy();
case EXTERN_MEMORY: return memory()->copy();
default: assert(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, though I don't think we want to abuse UNIMPLEMENTED, but define a similar UNREACHABLE. Do you mind including that with this PR?

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

Successfully merging this pull request may close these issues.

2 participants