https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125468
Bug ID: 125468
Summary: Compiling with modules and reflection has conflicting
declaration
Product: gcc
Version: 16.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: diltsman at gmail dot com
Target Milestone: ---
Created attachment 64557
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64557&action=edit
Preprocessed output
Given the following GCC version on Arch Linux:
```
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/16.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure
--enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust,cobol
--enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-cet=auto --enable-checking=release
--enable-clocale=gnu --enable-default-pie --enable-default-ssp
--enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror --disable-fixincludes
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.1.1 20260430 (GCC)
```
I have encountered a case that is fails to compile. Below are the commands to
compile, the minimal example case that I have been able to create, and the
compiler output.
The file compiles successfully if any of the following changes are made:
- Remove `-freflection` from the command line
- Remove the argument from `func`
- Change the argument type to `std::int32_t`
- Change the argument type to `std::exception`
- Delete the `#include`
- Replace the `import std;` with the appropriate `#include`
I am sure that there are other types that the argument could be changed to, but
those are the ones that I have tried.
```bash
g++ -std=c++26 -fmodules -fsearch-include-path bits/std.cc
g++ -std=c++26 -fmodules -freflection -Wall -Wextra -Wpedantic -c mod.cppm -o
mod.o
```
Minimum reproducible example:
```c++
module;
#include <sys/wait.h>
export module my_module;
import std;
auto func(std::string) {}
```
The error:
```none
In file included from /usr/include/sys/types.h:227,
from /usr/include/stdlib.h:518,
from /usr/include/c++/16.1.1/cstdlib:83,
from
/usr/include/c++/16.1.1/x86_64-pc-linux-gnu/bits/stdc++.h:39,
from /usr/include/c++/16.1.1/bits/std.cc:26,
of module std, imported at mod.cppm:6:
/usr/include/bits/pthreadtypes.h:72:3: error: conflicting imported declaration
‘typedef union pthread_mutex_t pthread_mutex_t’
72 | } pthread_mutex_t;
| ^~~~~~~~~~~~~~~
In file included from /usr/include/signal.h:375,
from /usr/include/sys/wait.h:36,
from mod.cppm:3:
/usr/include/bits/pthreadtypes.h:72:3: note: existing declaration ‘typedef
union pthread_mutex_t pthread_mutex_t’
72 | } pthread_mutex_t;
| ^~~~~~~~~~~~~~~
mod.cppm:8:16: note: during load of binding ‘std::string@std’
8 | auto func(std::string) {}
| ^~~~~~
```