Skip to content

clang: /root/llvm-project/clang/lib/AST/Expr.cpp:3289: bool clang::Expr::isConstantInitializer(clang::ASTContext&, bool, const clang::Expr**) const: Assertion `!isValueDependent() && "Expression evaluator can't be called on a dependent expression."' failed. #88008

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
danix800 opened this issue Apr 8, 2024 · 4 comments
Assignees
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" crash-on-invalid

Comments

@danix800
Copy link
Member

danix800 commented Apr 8, 2024

Clang trunk assertion failed on the following invalid initializer:

struct S {
	int v;
};

struct T;

void test(struct T *t)
{
	struct S s = { .v = t->y }; // t->y is invalid
}

https://godbolt.org/z/GnT41GbT5

Possibly similar to https://reviews.llvm.org/D84145.

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Apr 8, 2024
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" crash-on-invalid and removed clang Clang issues not falling into any other category labels Apr 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 8, 2024

@llvm/issue-subscribers-clang-frontend

Author: Ding Fei (danix800)

Clang trunk assertion failed on the following invalid initializer:
struct S {
	int v;
};

struct T;

void test(struct T *t)
{
	struct S s = { .v = t->y }; // t->y is invalid
}

https://godbolt.org/z/GnT41GbT5

Possibly similar to https://reviews.llvm.org/D84145.

@danix800 danix800 self-assigned this Apr 8, 2024
danix800 added a commit to danix800/llvm-project that referenced this issue Apr 8, 2024
…#88008)

Use refactored CheckForConstantInitializer() to skip checking expr with error.
@shafik
Copy link
Collaborator

shafik commented Apr 8, 2024

Looks like we had this since clang-12: https://godbolt.org/z/ohd4bMTEh

Perhaps here:

// If we couldn't parse the subelement, bail out.
if (SubElt.isUsable()) {
InitExprs.push_back(SubElt.get());
} else {
InitExprsOk = false;

we need if (SubElt.isUsable() && !SubElt.get()->containsErrors())

or maybe here:

if (Init.isInvalid()) {

We need if (Init.isInvalid() || Init.get()->containsErrors())

These are just some ideas from debugging the crash.

@danix800
Copy link
Member Author

danix800 commented Apr 9, 2024

Looks like we had this since clang-12: godbolt.org/z/ohd4bMTEh

Perhaps here:

// If we couldn't parse the subelement, bail out.
if (SubElt.isUsable()) {
InitExprs.push_back(SubElt.get());
} else {
InitExprsOk = false;

we need if (SubElt.isUsable() && !SubElt.get()->containsErrors())

or maybe here:

if (Init.isInvalid()) {

We need if (Init.isInvalid() || Init.get()->containsErrors())

These are just some ideas from debugging the crash.

Thanks for pointing this out. Could you please also take a look at PR #88014 . It might be more consistent as a fix.

danix800 added a commit to danix800/llvm-project that referenced this issue Apr 15, 2024
…#88008)

Use refactored CheckForConstantInitializer() to skip checking expr with error.
danix800 added a commit that referenced this issue Apr 16, 2024
…) (#88014)

Use refactored `CheckForConstantInitializer()` to skip checking expr
with error.

---------

Co-authored-by: Aaron Ballman <[email protected]>
@danix800 danix800 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 16, 2024
@shafik
Copy link
Collaborator

shafik commented Apr 18, 2024

Thanks for pointing this out. Could you please also take a look at PR #88014 . It might be more consistent as a fix.

Apologies, for the late reply. That looks like the right fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" crash-on-invalid
Projects
None yet
Development

No branches or pull requests

4 participants