https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124459
Bug ID: 124459
Summary: Ignoring a pragma directive inside a module
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: d7d1cd at mail dot ru
Target Milestone: ---
Created attachment 63901
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63901&action=edit
Source code of the module
The attached file contains the module's source code. Compile it with the
command:
$ g++ -std=c++26 -fmodules -c module.ixx -Wall
Use the resulting module in the following code:
$ cat main.cc
import M;
int main() {
foo(42);
bar(42);
}
Compile this code and receive a compiler warning, which we disabled:
$ g++ -std=c++26 -fmodules -c main.cc -Wall
Notably, the compiler ignores the pragma only if it appears in the code after
the preprocessor (function foo). If the pragma is added directly to the code,
the code compiles as expected, without warnings (function bar).
Here's a reproduction of the above example on godbolt:
https://godbolt.org/z/W7d4Y7sGq