Skip to content

[clang] Asserts in ADL when finding exported declaration in the implicit global module #109879

Closed
@mizvekov

Description

@mizvekov

Repro:

//--- A.cppm
module;
export module A;
export extern "C" void foo(struct Bar);

//--- B.cppm
module;
import A;
export module B;

//--- C.cpp
import B;
struct Bar {};
void test() {
  foo(Bar());
}

Crashes with:

Assertion failed: (FM && FM->isNamedModule() && !FM->isPrivateModule() && "bad export context"), function ArgumentDependentLookup, file SemaLookup.cpp, line 3854.

This is not just a crash on invalid. Slightly more complex, but valid, example:

//--- foo.h
struct Bar {};
extern "C" void foo(struct Bar);

//--- A.cppm
module;
#include "foo.h"
export module A;
export extern "C" using ::foo;
//--- B.cppm
module;
import A;
export module B;

//--- C.cpp
// expected-no-diagnostics
import B;
#include "foo.h"
void test() {
  foo(Bar());
}

It seems the comment above the assert is correct, but the assert itself is missing the implicit global module case, which is also in module purview.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions