https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115757
Bug ID: 115757
Summary: [modules] [[maybe_unused]] not honored in member
function of imported class template
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: rs2740 at gmail dot com
Target Milestone: ---
// test.cpp
module;
export module test;
export template<class = void>
class Foo {
public:
void foo(int n [[maybe_unused]]) { }
};
// main.cpp
import test;
int main() {
Foo f;
f.foo(1);
}
Produces the following warning with -Wall -Wextra
(https://godbolt.org/z/4vv15G9Yd):
In module test, imported at /app/main.cpp:2:
test.cpp: In instantiation of 'void Foo@test< <template-parameter-1-1>
>::foo(int) [with <template-parameter-1-1> = void]':
main.cpp:6:8: required from here
6 | f.foo(1);
| ~~~~~^~~
test.cpp:8:18: warning: unused parameter 'n' [-Wunused-parameter]
8 | void foo(int n [[maybe_unused]]) { }
| ~~~~^~~~~~~~~~~~~~~~~~
I would expect the attribute to suppress the warning. If Foo isn't a template
this works as expected.