Bug 109647 - ranges:6151:14: error: requires clause differs in template redeclaration rejected by clang++ 16.0.2
Summary: ranges:6151:14: error: requires clause differs in template redeclaration reje...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-27 11:46 UTC by Martin Liška
Modified: 2023-04-27 13:51 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2023-04-27 11:46:51 UTC
Apparently, clang++ 16.0.2 can't digest libstdc++ version of ranges header file:

echo '#include <ranges>' | clang++ -x c++ - -c -std=c++2b
In file included from <stdin>:1:
/usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13/ranges:6151:14: error: requires clause differs in template redeclaration
    requires forward_range<_Vp>
             ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13/ranges:5850:14: note: previous template declaration is here
    requires input_range<_Vp>
             ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13/ranges:8846:20: error: type-id cannot have a name
    { return (auto(__x) += __y); }
                   ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13/ranges:8846:25: error: expected ')'
    { return (auto(__x) += __y); }
                        ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13/ranges:8846:14: note: to match this '('
    { return (auto(__x) += __y); }
             ^
/usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13/ranges:8846:32: error: expected expression
    { return (auto(__x) += __y); }
                               ^
4 errors generated.

$ echo '#include <ranges>' | g++-13 -x c++ - -c -std=c++2b
(ok)
Comment 1 Jonathan Wakely 2023-04-27 12:10:41 UTC
This is a clang bug.

The primary template on line 5850 has these constraints:

  template<view _Vp>
    requires input_range<_Vp>
  class chunk_view : public view_interface<chunk_view<_Vp>>


But then there is a partial specialization for forward_range on line 6075:

  template<view _Vp>
    requires forward_range<_Vp>
  class chunk_view<_Vp> : public view_interface<chunk_view<_Vp>>

The error on line 6151 incorrectly says that the definition is inconstistent with line 5850. That's true, but it's a definition for the one on line 6075 instead.
Comment 2 Jonathan Wakely 2023-04-27 12:12:45 UTC
As already explained in Bug 96830 comment 8 

This is https://github.com/llvm/llvm-project/issues/49620 which is fixed on trunk, but still present in Clang 16.0.0