Package: g++-11 Version: 11.2.0-4 Severity: normal Dear Maintainer,
* What led up to the situation? While performing some tests using modules I first defined a module defining a class type. Its compilation completed flawlessly. Next I defined a module partition defining a class type. It's compilation failed. * What exactly did you do (or not do) that was effective (or ineffective)? First the module that was successfully compiled: I defined the following module interface (in, e.g., 'module.cc'): ----------------------------- export module mod; export class Data { int d_value = 10; public: int value() const; }; ----------------------------- and the implementation of value() (in, e.g., 'value.cc'): ----------------------------- module mod; int Data::value() const { return d_value; } ----------------------------- to compile I issued: g++-11 -c -std=c++20 -fmodules-ts module.cc value.cc compilation completed flawlessly. Next the module partition whose compilation failed: I defined (in a difference directory as used for the above source files) the following module partition interface (e.g., 'partition.cc)': ----------------------------- export module mod:partition; export class Data { int d_value = 10; public: int value() const; }; ----------------------------- and the implementation of value() (in, e.g., 'value.cc'): ----------------------------- module mod:partition; int Data::value() const { return d_value; } ----------------------------- to compile I issued: g++-11 -c -std=c++20 -fmodules-ts partition.cc value.cc compilation of value failed. * What was the outcome of this action? The compiler produced the following error messages: value.cc:3:5: error: ‘Data’ has not been declared 3 | int Data::value() const | ^~~~ value.cc:3:19: error: non-member function ‘int value()’ cannot have cv-qualifier 3 | int Data::value() const | ^~~~~ value.cc: In function ‘int value()’: value.cc:5:12: error: ‘d_value’ was not declared in this scope; did you mean ‘value’? 5 | return d_value; | ^~~~~~~ * What outcome did you expect instead? Since the compilation of the plain module completed without errors, and since a partition is a subsection of a module, without any special restrictions w.r.t the kind of elements it can contain, I would have expected that the compilation of the partition's 'value.cc' would succeed as well. It's OK to define mere variables or functions in partitions, but currently implementations of members of classes whose interfaces are provided in module partition interface files produces errors, which comes as a surprise. -- System Information: Debian Release: bookworm/sid APT prefers testing APT policy: (500, 'testing'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 5.10.0-8-amd64 (SMP w/4 CPU threads) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages g++-11 depends on: ii gcc-11 11.2.0-4 ii gcc-11-base 11.2.0-4 ii libc6 2.32-4 ii libgmp10 2:6.2.1+dfsg-2 ii libisl23 0.23-1 ii libmpc3 1.2.0-1 ii libmpfr6 4.1.0-3 ii libstdc++-11-dev 11.2.0-4 ii libzstd1 1.4.8+dfsg-2.1 ii zlib1g 1:1.2.11.dfsg-2 g++-11 recommends no packages. Versions of packages g++-11 suggests: pn g++-11-multilib <none> pn gcc-11-doc <none> -- debconf-show failed