public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107188] New: using concept type-constraint declared in nested namespace causes incorrect compilation error
@ 2022-10-09  0:29 Mark_B53 at yahoo dot com
  2022-10-10 13:55 ` [Bug c++/107188] " ppalka at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mark_B53 at yahoo dot com @ 2022-10-09  0:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107188

            Bug ID: 107188
           Summary: using concept type-constraint declared in nested
                    namespace causes incorrect compilation error
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Mark_B53 at yahoo dot com
  Target Milestone: ---

#include <concepts>
#include <ranges>
#include <vector>
namespace ns1 {
template <typename T, typename V>
concept RangeV = std::ranges::range<T> &&
std::same_as<std::ranges::range_value_t<T>, V>;
}
namespace ns2 {
ns1::RangeV<int> auto fn() { return std::vector<int>{}; }      // compiles
struct X {
    ns1::RangeV<int> auto fn() { return std::vector<int>{}; }  // fails to
compile (bug!)
};
using ns1::RangeV;
struct Y {
    RangeV<int> auto fn() { return std::vector<int>{}; }       // compiles
};
}

-----

<source>:11:10: error: wrong number of template arguments (1, should be 2)
   11 |     ns1::RangeV<int> auto fn() { return std::vector<int>{}; }  // fails
to compile (bug!)
      |          ^~~~~~~~~~~
<source>:6:9: note: provided for 'template<class T, class V> concept
ns1::RangeV'
    6 | concept RangeV = std::ranges::range<T> &&
std::same_as<std::ranges::range_value_t<T>, V>;


-----

g++ a.cpp -std=c++20

Using built-in specs.
COLLECT_GCC=/opt/compiler-explorer/gcc-snapshot/bin/g++
Target: x86_64-linux-gnu
Configured with: ../gcc-trunk-20221008/configure
--prefix=/opt/compiler-explorer/gcc-build/staging --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-bootstrap
--enable-multiarch --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --enable-clocale=gnu
--enable-languages=c,c++,fortran,ada,objc,obj-c++,d --enable-ld=yes
--enable-gold=yes --enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-linker-build-id --enable-lto --enable-plugins --enable-threads=posix
--with-pkgversion=Compiler-Explorer-Build-gcc-895dd027d5dda51a95d242aec8a49a6dfa5db58d-binutils-2.38
--enable-libstdcxx-backtrace=yes
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20221007 (experimental)
(Compiler-Explorer-Build-gcc-895dd027d5dda51a95d242aec8a49a6dfa5db58d-binutils-2.38) 
COLLECT_GCC_OPTIONS='-fdiagnostics-color=always' '-g' '-o' '/app/output.s'
'-masm=intel' '-S' '-v' '-std=c++20' '-isystem'
'/opt/compiler-explorer/libs/boost_1_80_0' '-shared-libgcc' '-mtune=generic'
'-march=x86-64' '-dumpdir' '/app/'

/opt/compiler-explorer/gcc-trunk-20221008/bin/../libexec/gcc/x86_64-linux-gnu/13.0.0/cc1plus
-quiet -v -imultiarch x86_64-linux-gnu -iprefix
/opt/compiler-explorer/gcc-trunk-20221008/bin/../lib/gcc/x86_64-linux-gnu/13.0.0/
-D_GNU_SOURCE -isystem /opt/compiler-explorer/libs/boost_1_80_0 <source> -quiet
-dumpdir /app/ -dumpbase output.cpp -dumpbase-ext .cpp -masm=intel
-mtune=generic -march=x86-64 -g -std=c++20 -version -fdiagnostics-color=always
-o /app/output.s
GNU C++20
(Compiler-Explorer-Build-gcc-895dd027d5dda51a95d242aec8a49a6dfa5db58d-binutils-2.38)
version 13.0.0 20221007 (experimental) (x86_64-linux-gnu)
        compiled by GNU C version 9.4.0, GMP version 6.2.1, MPFR version 4.1.0,
MPC version 1.2.1, isl version isl-0.24-GMP

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/107188] using concept type-constraint declared in nested namespace causes incorrect compilation error
  2022-10-09  0:29 [Bug c++/107188] New: using concept type-constraint declared in nested namespace causes incorrect compilation error Mark_B53 at yahoo dot com
@ 2022-10-10 13:55 ` ppalka at gcc dot gnu.org
  2022-12-15 21:08 ` cvs-commit at gcc dot gnu.org
  2024-03-08 21:46 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-10-10 13:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107188

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
                 CC|                            |ppalka at gcc dot gnu.org
   Last reconfirmed|                            |2022-10-10
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, not a regression.  Reduced:

namespace N {
  template<class, class> concept C = true;
}

struct X {
  N::C<int> auto f() { return 0; }
};

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/107188] using concept type-constraint declared in nested namespace causes incorrect compilation error
  2022-10-09  0:29 [Bug c++/107188] New: using concept type-constraint declared in nested namespace causes incorrect compilation error Mark_B53 at yahoo dot com
  2022-10-10 13:55 ` [Bug c++/107188] " ppalka at gcc dot gnu.org
@ 2022-12-15 21:08 ` cvs-commit at gcc dot gnu.org
  2024-03-08 21:46 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-15 21:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107188

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:147e276b580b674a46bc3b9c461ae7837fd48aba

commit r13-4731-g147e276b580b674a46bc3b9c461ae7837fd48aba
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Dec 15 16:07:09 2022 -0500

    c++: class-scope qualified constrained auto [PR107188]

    Here when parsing the class-scope auto constrained by a qualified
    concept-id, we first tentatively parse the overall member-declaration as
    a deprecated access-declaration, during which we parse C<int> as a
    standalone TEMPLATE_ID_EXPR (separate from the auto) and end up emitting
    the stray error

    concepts-placeholder11.C:9:6: error: wrong number of template arguments (1,
should be 2)
        9 |   N::C<int> auto f() { return 0; }
          |      ^~~~~~
    concepts-placeholder11.C:5:34: note: provided for âtemplate<class, class>
concept N::Câ
        5 |   template<class, class> concept C = true;
          |                                  ^

    from build_concept_id called from cp_parser_template_id_expr.

    We could fix this by adding a complain parameter to build_concept_id and
    passing tf_none when parsing tentatively.  However, it seems this can
    also be fixed in a more general way that might benefit non-concepts
    code: when tentatively parsing an access-declaration, abort the parse
    early if the qualifying scope isn't possibly a class or enumeration
    type, so that we avoid parsing C<int> as a TEMPLATE_ID_EXPR here in the
    first place.  This patch takes this latter approach.

            PR c++/107188

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_using_declaration): Give up early if the
            scope of an access-declaration isn't possibly a class type.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-placeholder11.C: New test.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/107188] using concept type-constraint declared in nested namespace causes incorrect compilation error
  2022-10-09  0:29 [Bug c++/107188] New: using concept type-constraint declared in nested namespace causes incorrect compilation error Mark_B53 at yahoo dot com
  2022-10-10 13:55 ` [Bug c++/107188] " ppalka at gcc dot gnu.org
  2022-12-15 21:08 ` cvs-commit at gcc dot gnu.org
@ 2024-03-08 21:46 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-08 21:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107188

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |13.0
             Status|ASSIGNED                    |RESOLVED

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed in GCC 13

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-08 21:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-09  0:29 [Bug c++/107188] New: using concept type-constraint declared in nested namespace causes incorrect compilation error Mark_B53 at yahoo dot com
2022-10-10 13:55 ` [Bug c++/107188] " ppalka at gcc dot gnu.org
2022-12-15 21:08 ` cvs-commit at gcc dot gnu.org
2024-03-08 21:46 ` ppalka 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).