public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113405] New: Can't access member type alias of concept-constrained class template specialization in global module fragment via alias template in different module
@ 2024-01-15 19:41 eddiejnolan at gmail dot com
2024-01-15 19:51 ` [Bug c++/113405] " pinskia at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: eddiejnolan at gmail dot com @ 2024-01-15 19:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113405
Bug ID: 113405
Summary: Can't access member type alias of concept-constrained
class template specialization in global module
fragment via alias template in different module
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: eddiejnolan at gmail dot com
Target Milestone: ---
This example shows GCC failing to resolve the member type alias "foobar" in a
concept-constrained specialization of class template "corge" when it's accessed
from module2 via an alias template in module1.
Compiler explorer link: https://godbolt.org/z/4sh6xG6P4
Minimal reproduction:
// CMakeLists.txt
cmake_minimum_required(VERSION 3.28)
project(repro CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_library(module1)
target_sources(module1
PUBLIC
FILE_SET cxx_modules TYPE CXX_MODULES FILES
module1.cpp
)
target_include_directories(module1 PRIVATE "include/")
add_library(module2)
target_sources(module2
PUBLIC
FILE_SET cxx_modules TYPE CXX_MODULES FILES
module2.cpp
)
target_link_libraries(module2 PUBLIC module1)
// include/foo.h
template <typename>
concept foo = false;
template <typename>
concept bar = true;
template <typename>
struct corge {};
template <foo T>
struct corge<T> {};
template <bar T>
struct corge<T> {
using foobar = int;
};
// module1.cpp
module;
#include "foo.h"
export module module1;
export template<class T>
using corge_alias = corge<T>::foobar;
// module2.cpp
export module module2;
import module1;
struct foobaz{};
using quux = corge_alias<foobaz>;
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/113405] Can't access member type alias of concept-constrained class template specialization in global module fragment via alias template in different module
2024-01-15 19:41 [Bug c++/113405] New: Can't access member type alias of concept-constrained class template specialization in global module fragment via alias template in different module eddiejnolan at gmail dot com
@ 2024-01-15 19:51 ` pinskia at gcc dot gnu.org
2024-01-15 21:33 ` eddiejnolan at gmail dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-15 19:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113405
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |103524
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
It would be useful if you don't use cmake here since it is so simple to figure
out the full command line for building here.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103524
[Bug 103524] [meta-bug] modules issue
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/113405] Can't access member type alias of concept-constrained class template specialization in global module fragment via alias template in different module
2024-01-15 19:41 [Bug c++/113405] New: Can't access member type alias of concept-constrained class template specialization in global module fragment via alias template in different module eddiejnolan at gmail dot com
2024-01-15 19:51 ` [Bug c++/113405] " pinskia at gcc dot gnu.org
@ 2024-01-15 21:33 ` eddiejnolan at gmail dot com
2024-01-15 22:20 ` eddiejnolan at gmail dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: eddiejnolan at gmail dot com @ 2024-01-15 21:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113405
--- Comment #2 from Eddie Nolan <eddiejnolan at gmail dot com> ---
This series of commands reproduces the issue and does not use CMake:
g++ -g -std=c++20 -E -x c++ ./module2.cpp \
-MT ./module2.cpp.o.ddi -MD -MF ./module2.cpp.o.ddi.d \
-fmodules-ts -fdeps-file=./module2.cpp.o.ddi -fdeps-target=./module2.cpp.o
\
-fdeps-format=p1689r5 -o ./module2.cpp.o.ddi.i
g++ -I./include -g -std=c++20 -E -x c++ ./module1.cpp \
-MT ./module1.cpp.o.ddi -MD -MF ./module1.cpp.o.ddi.d \
-fmodules-ts -fdeps-file=./module1.cpp.o.ddi -fdeps-target=./module1.cpp.o
\
-fdeps-format=p1689r5 -o ./module1.cpp.o.ddi.i
echo "module1 module1.gcm" >> ./module1.cpp.o.modmap
echo "module2 module2.gcm" >> ./module2.cpp.o.modmap
echo "module1 module1.gcm" >> ./module2.cpp.o.modmap
g++ -I./include -g -std=c++20 -MD -MT ./module1.cpp.o -MF ./module1.cpp.o.d \
-fmodules-ts -fmodule-mapper=./module1.cpp.o.modmap -MD \
-fdeps-format=p1689r5 -x c++ -o ./module1.cpp.o -c ./module1.cpp
g++ -g -std=c++20 -MD -MT ./module2.cpp.o -MF ./module2.cpp.o.d \
-fmodules-ts -fmodule-mapper=./module2.cpp.o.modmap -MD \
-fdeps-format=p1689r5 -x c++ -o ./module2.cpp.o -c ./module2.cpp
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/113405] Can't access member type alias of concept-constrained class template specialization in global module fragment via alias template in different module
2024-01-15 19:41 [Bug c++/113405] New: Can't access member type alias of concept-constrained class template specialization in global module fragment via alias template in different module eddiejnolan at gmail dot com
2024-01-15 19:51 ` [Bug c++/113405] " pinskia at gcc dot gnu.org
2024-01-15 21:33 ` eddiejnolan at gmail dot com
@ 2024-01-15 22:20 ` eddiejnolan at gmail dot com
2024-01-19 3:38 ` nathanieloshead at gmail dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: eddiejnolan at gmail dot com @ 2024-01-15 22:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113405
--- Comment #3 from Eddie Nolan <eddiejnolan at gmail dot com> ---
Fixed (first two commands were superfluous):
echo "module1 module1.gcm" >> ./module1.cpp.o.modmap
echo "module2 module2.gcm" >> ./module2.cpp.o.modmap
echo "module1 module1.gcm" >> ./module2.cpp.o.modmap
g++ -I./include -g -std=c++20 -MD -MT ./module1.cpp.o -MF ./module1.cpp.o.d \
-fmodules-ts -fmodule-mapper=./module1.cpp.o.modmap -MD \
-fdeps-format=p1689r5 -x c++ -o ./module1.cpp.o -c ./module1.cpp
g++ -g -std=c++20 -MD -MT ./module2.cpp.o -MF ./module2.cpp.o.d \
-fmodules-ts -fmodule-mapper=./module2.cpp.o.modmap -MD \
-fdeps-format=p1689r5 -x c++ -o ./module2.cpp.o -c ./module2.cpp
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/113405] Can't access member type alias of concept-constrained class template specialization in global module fragment via alias template in different module
2024-01-15 19:41 [Bug c++/113405] New: Can't access member type alias of concept-constrained class template specialization in global module fragment via alias template in different module eddiejnolan at gmail dot com
` (2 preceding siblings ...)
2024-01-15 22:20 ` eddiejnolan at gmail dot com
@ 2024-01-19 3:38 ` nathanieloshead at gmail dot com
2024-01-25 3:20 ` cvs-commit at gcc dot gnu.org
2024-01-27 10:19 ` nshead at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: nathanieloshead at gmail dot com @ 2024-01-19 3:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113405
Nathaniel Shead <nathanieloshead at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nathanieloshead at gmail dot com
--- Comment #4 from Nathaniel Shead <nathanieloshead at gmail dot com> ---
The issue seems to be that 'depset::hash::add_specializations' only adds the
first of a set of constrained specialisations that use the same arguments. This
comes down to the fact that the 'type_specializations' hashset is only hashed
on the base template and the provided arguments: differently constrained
specialisations just aren't added.
Other parts of the dependency walker seem to handle this OK, by walking the
DECL_TEMPLATE_SPECIALIZATIONS list, but not the base 'specialization_add'
function.
I'm not entirely sure yet what the best way to approach solving this is.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/113405] Can't access member type alias of concept-constrained class template specialization in global module fragment via alias template in different module
2024-01-15 19:41 [Bug c++/113405] New: Can't access member type alias of concept-constrained class template specialization in global module fragment via alias template in different module eddiejnolan at gmail dot com
` (3 preceding siblings ...)
2024-01-19 3:38 ` nathanieloshead at gmail dot com
@ 2024-01-25 3:20 ` cvs-commit at gcc dot gnu.org
2024-01-27 10:19 ` nshead at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-25 3:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113405
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nshead@gcc.gnu.org>:
https://gcc.gnu.org/g:6ff54cc0be8dfa9d9bd5922ec65e86c9eb644711
commit r14-8408-g6ff54cc0be8dfa9d9bd5922ec65e86c9eb644711
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date: Fri Jan 19 22:24:18 2024 +1100
c++: Handle partial specialisations in GMF [PR113405]
Currently, when exporting names from the GMF, or within header modules,
for a set of constrained partial specialisations we only emit the first
one. This is because the 'type_specialization' list only includes a
single specialization per template+argument list; constraints are not
considered here.
The existing code uses a separate 'partial_specializations' list to
track this instead, but currently it's only used for declarations in the
module purview. This patch makes use of this list for all declarations.
PR c++/113405
gcc/cp/ChangeLog:
* module.cc (set_defining_module): Track partial specialisations
for all declarations.
gcc/testsuite/ChangeLog:
* g++.dg/modules/concept-9.h: New test.
* g++.dg/modules/concept-9_a.C: New test.
* g++.dg/modules/concept-9_b.C: New test.
* g++.dg/modules/concept-10_a.H: New test.
* g++.dg/modules/concept-10_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/113405] Can't access member type alias of concept-constrained class template specialization in global module fragment via alias template in different module
2024-01-15 19:41 [Bug c++/113405] New: Can't access member type alias of concept-constrained class template specialization in global module fragment via alias template in different module eddiejnolan at gmail dot com
` (4 preceding siblings ...)
2024-01-25 3:20 ` cvs-commit at gcc dot gnu.org
@ 2024-01-27 10:19 ` nshead at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-01-27 10:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113405
Nathaniel Shead <nshead at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
Assignee|unassigned at gcc dot gnu.org |nshead at gcc dot gnu.org
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Fixed for GCC 14.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-01-27 10:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-15 19:41 [Bug c++/113405] New: Can't access member type alias of concept-constrained class template specialization in global module fragment via alias template in different module eddiejnolan at gmail dot com
2024-01-15 19:51 ` [Bug c++/113405] " pinskia at gcc dot gnu.org
2024-01-15 21:33 ` eddiejnolan at gmail dot com
2024-01-15 22:20 ` eddiejnolan at gmail dot com
2024-01-19 3:38 ` nathanieloshead at gmail dot com
2024-01-25 3:20 ` cvs-commit at gcc dot gnu.org
2024-01-27 10:19 ` nshead at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).