#1073932 libstdc++-14-dev: 'using' specification results in compiler error when specifying -fmodules-ts

Package:
libstdc++-14-dev
Source:
libstdc++-14-dev
Description:
GNU Standard C++ Library v3 (development files)
Submitter:
Frank B. Brokken
Date:
2024-08-29 11:15:02 UTC
Severity:
normal
Tags:
#1073932#5
Date:
2024-06-20 12:32:48 UTC
From:
To:
Dear Maintainer,

   * What led up to the situation?

When specifying a 'using' declaration the compiler produces an error when the
-fmodules-ts flag is used.

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

The following program compiles correctly when -fmodules is *not* specified,
and produces an error when -fmodules *is* specified. In the latter case: if
instead of the #include directives 'import' statements (like 'import
<vector>;' are used the same error results. But when '#include <iostream>' (or
'import <iostream>;' is omitted compilation using the -fmodules-ts flag
correctly completes.

The following source file (between ======= lines) was compiled by calling:
        g++ --std=c++23 -Wall -fmodules-ts -freport-bug -c main.cc


===================================================
    #include <iostream>
    #include <vector>

    int main()
    {
        using VectorInt = std::vector<int>;

        VectorInt vi(3);
    }
===================================================

   * What was the outcome of this action?

main.cc: In function ‘int main()’:
main.cc:6:38: error: wrong number of template arguments (1, should be 2)
    6 |     using VectorInt = 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 main.cc:1:
/usr/include/c++/14/format:2577:36: note: provided for ‘template<class, class> class std::vector’
 2577 | template<typename, typename> class vector;
      |                                    ^~~~~~
main.cc:6:28: error: ‘<expression error>’ in namespace ‘std’ does not name a type
    6 |     using VectorInt = std::vector<int>;
      |                            ^~~~~~~~~~~
main.cc:8:5: error: ‘VectorInt’ was not declared in this scope
    8 |     VectorInt vi(3);
      |     ^~~~~~~~~


   * What outcome did you expect instead?

    The same as when -fmodule-ts is not specified: errorless compilation

#1073932#10
Date:
2024-08-29 11:12:11 UTC
From:
To:
please could you recheck, also with the gcc-snapshot package?

and an example script or Makefile maybe better for a reproducer.