Package: g++-14
Version: 14.2.0-8
Severity: normal

Dear Maintainer,

   * What led up to the situation?

When constructing a module file changing the order of importing system header
files may result in a compilation failure.

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

First, as root, I module-compiled /usr/include/c++/14 iostream and vector
using (in that directory) the commands

        g++ --std=c++26 -fmodules-ts -x c++-system-header iostream
        g++ --std=c++26 -fmodules-ts -x c++-system-header vector
and
        mv gcm.cache/usr/include/c++/14/*.gcm .

Next (as a non-root user) I prepared the file ~/tmp/module.cc

    export module Mod;
    
    export import <iostream>;
    export import <vector>;
    
    export
    {
        class Class
        {
            using IV = std::vector<int>;
        };
    }

and defined the subdirectory gcm.cache and a soft-link:

    cd ~/tmp
    mkdir gcm.cache
    ln -s /usr gcm.cache

Finally the compiler was called to compile module.cc:

    g++ -c -fmodules-ts --std=c++26 module.cc

   * What was the outcome of this action?

The compiler reported the following errors

    module.cc:11:35: error: wrong number of template arguments (1, should be 2)
       11 |         using IV = std::vector<int>;
          |                                   ^
    In file included from /usr/include/c++/14/ostream:43,
                     from /usr/include/c++/14/iostream:41,
    of module /usr/include/c++/14/iostream, imported at module.cc:3:
    /usr/include/c++/14/format:2580:36: note: provided for ‘template<class, 
class> class std::vector’
     2580 | template<typename, typename> class vector;
          |                                    ^~~~~~
    module.cc:11:25: error: ‘<expression error>’ in namespace ‘std’ does not 
name a type
       11 |         using IV = std::vector<int>;
          |                         ^~~~~~~~~~~
    module.cc:1:8: warning: not writing module ‘Mod’ due to errors
        1 | export module Mod;
          |        ^~~~~~


   * What outcome did you expect instead?

No errors. When using #include precompiler directives no errors are
reported. 

But also: no errors are reported when reversing the order of the
'import' instructions. E.g., with 

    export module Mod;
    
    export import <vector>;
    export import <iostream>;
    
    export
    {
        class Class
        {
            // commeented out using or reset: OK
            using IV = std::vector<int>;
        };
    }

the compilation completed flawlessly. 


-- System Information:
Debian Release: trixie/sid
  APT prefers testing
  APT policy: (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 6.12.6-amd64 (SMP w/2 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages g++-14 depends on:
ii  g++-14-x86-64-linux-gnu  14.2.0-8
ii  gcc-14                   14.2.0-8
ii  gcc-14-base              14.2.0-8

g++-14 recommends no packages.

Versions of packages g++-14 suggests:
pn  g++-14-multilib  <none>
pn  gcc-14-doc       <none>

-- no debconf information

Reply via email to