Skip to content

[C++][Modules] Definition with same mangled name for template arguments of types defined in unnamed namespace in different files #119947

Closed
@davidstone

Description

@davidstone

Given the following translation units:

export module a;

struct a_inner {
	~a_inner() {
	}
	void f(auto) {
	}
};

export template<typename T>
struct a {
	a() {
		struct local {};
		inner.f(local());
	}
private:
	a_inner inner;
};


namespace {

struct s {
};

} // namespace

void f() {
	a<s> x;
}
import a;

namespace {

struct s {
};

} // namespace

void g() {
	a<s> x;
}

clang fails with

/opt/compiler-explorer/clang-assertions-trunk/bin/clang++ --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot   -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 -MD -MT CMakeFiles/foo.dir/b.cpp.o -MF CMakeFiles/foo.dir/b.cpp.o.d @CMakeFiles/foo.dir/b.cpp.o.modmap -o CMakeFiles/foo.dir/b.cpp.o -c /app/b.cpp
In file included from /app/b.cpp:1:
a.cpp:11:8: error: definition with same mangled name '_ZNW1a1aIN12_GLOBAL__N_11sEED2Ev' as another definition
   11 | struct a {
      |        ^
a.cpp:11:8: note: previous definition is here

See it live: https://godbolt.org/z/vsdznvsbP

Metadata

Metadata

Assignees

Labels

clang:modulesC++20 modules and Clang Header Modules

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions