Skip to content

clang crashes when an enum forward declaration is used in cast #8461

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

Closed
llvmbot opened this issue Sep 6, 2010 · 3 comments
Closed

clang crashes when an enum forward declaration is used in cast #8461

llvmbot opened this issue Sep 6, 2010 · 3 comments
Labels
bugzilla Issues migrated from bugzilla c++

Comments

@llvmbot
Copy link
Member

llvmbot commented Sep 6, 2010

Bugzilla Link 8089
Resolution FIXED
Resolved on Sep 11, 2010 22:41
Version trunk
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @DougGregor

Extended Description

test.cpp:
enum E;
int a = (E)3;

clang -cc1 -fsyntax-only test.cpp

stack dump.

@llvmbot
Copy link
Member Author

llvmbot commented Sep 8, 2010

So, I guess since you discovered this, this means that something actually uses this and expects it to work? Or does it come from genuinely invalid code?

The crash actually occurs when implicitly converting the incomplete enum type back to int in the initialization. We check if this is an integral promotion, and for this we attempt to get the enum's promoted type. But that type hasn't been computed for the incomplete enum, so null is returned, which we eventually access.

There's something very fishy about that code, aside from crashing.

Anyway, the question is, what result do we want for this?

@llvmbot
Copy link
Member Author

llvmbot commented Sep 8, 2010

I discovered this bug while investigating what is needed to support enum foward declaration in -fms-extensions mode. MSVC allows such code to compile.

I am preparing a patch to assign an underying type to an incomplete enum in msvc mode.

Without -fms-extensions we just want clang to emit a meaningful diagnostic instead of crashing.

@DougGregor
Copy link
Contributor

Fixed in Clang r113711.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
augusto2112 pushed a commit to augusto2112/llvm-project that referenced this issue Mar 25, 2024
Disable driver tests on macosx that are currently disabled on darwin
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++
Projects
None yet
Development

No branches or pull requests

2 participants