[Bug c++/93283] New: Partial specialization not specializing any parameters is allowed with alias templates

2020-01-15 Thread omerfaruko at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93283

Bug ID: 93283
   Summary: Partial specialization not specializing any parameters
is allowed with alias templates
   Product: gcc
   Version: 9.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: omerfaruko at gmail dot com
  Target Milestone: ---

Partial specializations with template aliases are allowed even if they don't
specialize any template arguments.

Taken from https://stackoverflow.com/q/59756201/7771076.

https://godbolt.org/z/Ne9Tav



// okay
#include 

template
using sfinae_t = T;

template 
struct Test;

template 
struct Test> {};

Test t;



// fail
#include 

template
using sfinae_t = T;

template 
struct Test;

template 
struct Test> {};

Test t;



Error message for the latter:

:10:8: error: partial specialization 'struct Test' does not
specialize any template arguments; to define the primary template, remove the
template argument list
   10 | struct Test> {};
  |^
:7:8: note: primary template here
7 | struct Test;
  |



There is a separate discussion on whether this is valid:

https://godbolt.org/z/ztuRSq



#include 

template
using sfinae_t = T;

template
using sfinae_v_t = sfinae_t::type...>;

template 
struct Test;

template 
struct Test>> {};

void f() {
Test t;
}



This compiles fine with gcc (possibly due to above bug), but not with
clang/icc/MSVC.

The last one is actually useful for specializing std::hash, std::tuple_size,
std::tuple_element etc. based on user's template types.

Thanks.

[Bug c++/121175] New: [modules] ICE with explicit specialization of template class (internal compiler error: in tree_node, at cp/module.cc:9975)

2025-07-19 Thread omerfaruko at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121175

Bug ID: 121175
   Summary: [modules] ICE with explicit specialization of template
class (internal compiler error: in tree_node, at
cp/module.cc:9975)
   Product: gcc
   Version: 15.1.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: omerfaruko at gmail dot com
  Target Milestone: ---

Created attachment 61916
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61916&action=edit
preprocessed source

Confirmed with g++ (GCC) 15.1.1 20250425 and with build from
https://gcc.gnu.org/pub/gcc/snapshots/15-20250712/ snapshot.

reprod.ccm:

```cpp
module;

#include 

export module reprod;

export struct Reprod {};

template <> struct std::formatter {
  auto parse(std::format_parse_context &ctx) { return ctx.begin(); }

  template 
  auto format(Reprod value, FormatContext &ctx) const {
return std::format_to(ctx.out(), "Reprod");
  }
};
```

CMakeLists.txt:

```cmake
cmake_minimum_required(VERSION 4.0)
project(reprod)

set(CMAKE_CXX_FLAGS "-fsanitize=undefined")
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_library(reprod)
target_sources(reprod
PRIVATE
  FILE_SET CXX_MODULES
  FILES
reprod.ccm
)

```

mkdir build && cd build && cmake .. && ninja --verbose:

```
-- The C compiler identification is GNU 15.1.1
-- The CXX compiler identification is GNU 15.1.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/gcc-15-20250712/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/gcc-15-20250712/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /home/omer/src/reprod/build
[1/4] /opt/gcc-15-20250712/bin/g++   -fsanitize=undefined -std=c++23 -E -x c++
/home/omer/src/reprod/reprod.ccm -MT CMakeFiles/reprod.dir/reprod.ccm.o.ddi -MD
-MF CMakeFiles/reprod.dir/reprod.ccm.o.ddi.d -fmodules-ts
-fdeps-file=CMakeFiles/reprod.dir/reprod.ccm.o.ddi
-fdeps-target=CMakeFiles/reprod.dir/reprod.ccm.o -fdeps-format=p1689r5 -o
CMakeFiles/reprod.dir/reprod.ccm.o.ddi.i
[2/4] /usr/bin/cmake -E cmake_ninja_dyndep
--tdi=CMakeFiles/reprod.dir/CXXDependInfo.json --lang=CXX --modmapfmt=gcc
--dd=CMakeFiles/reprod.dir/CXX.dd @CMakeFiles/reprod.dir/CXX.dd.rsp
[3/4] /opt/gcc-15-20250712/bin/g++   -fsanitize=undefined -std=c++23 -MD -MT
CMakeFiles/reprod.dir/reprod.ccm.o -MF CMakeFiles/reprod.dir/reprod.ccm.o.d
-fmodules-ts -fmodule-mapper=CMakeFiles/reprod.dir/reprod.ccm.o.modmap -MD
-fdeps-format=p1689r5 -x c++ -o CMakeFiles/reprod.dir/reprod.ccm.o -c
/home/omer/src/reprod/reprod.ccm
FAILED: CMakeFiles/reprod.dir/reprod.ccm.o CMakeFiles/reprod.dir/reprod.gcm
/opt/gcc-15-20250712/bin/g++   -fsanitize=undefined -std=c++23 -MD -MT
CMakeFiles/reprod.dir/reprod.ccm.o -MF CMakeFiles/reprod.dir/reprod.ccm.o.d
-fmodules-ts -fmodule-mapper=CMakeFiles/reprod.dir/reprod.ccm.o.modmap -MD
-fdeps-format=p1689r5 -x c++ -o CMakeFiles/reprod.dir/reprod.ccm.o -c
/home/omer/src/reprod/reprod.ccm
/home/omer/src/reprod/reprod.ccm:5:8: internal compiler error: in tree_node, at
cp/module.cc:9975
5 | export module reprod;
  |^~
0x22e8325 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x22f85bf internal_error(char const*, ...)
???:0
0x7d1dc3 fancy_abort(char const*, int, char const*)
???:0
0x8ee353 depset::hash::find_dependencies(module_state*)
???:0
0x8ef121 module_state::write_begin(elf_out*, cpp_reader*, module_state_config&,
unsigned int&)
???:0
0x8f07f3 finish_module_processing(cpp_reader*)
???:0
0x88c661 c_parse_final_cleanups()
???:0
0xa8a510 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
ninja: build stopped: subcommand failed.
```

Preprocessed source is attached:

```
/opt/gcc-15-20250712/bin/g++   -fsanitize=undefined -std=c++23 -MD -MT
CMakeFiles/reprod.dir/reprod.ccm.o -MF CMakeFiles/reprod.dir/reprod.ccm.o.d
-fmodules-ts -fmodule-mapper=CMakeFiles/reprod.dir/reprod.ccm.o.modmap -MD
-fdeps-format=p1689r5 -x c++ -o CMakeFiles/reprod.dir/reprod.ccm.o -c
/home/omer/src/reprod/reprod.ccm -freport-bug
```