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.