Bug 88075 - [feature-request] allow "concept" instead of "concept bool" with -fconcepts
Summary: [feature-request] allow "concept" instead of "concept bool" with -fconcepts
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.3.1
: P3 normal
Target Milestone: 8.4
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: concepts
  Show dependency treegraph
 
Reported: 2018-11-18 16:57 UTC by Hannes Hauswedell
Modified: 2019-11-16 23:51 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hannes Hauswedell 2018-11-18 16:57:23 UTC
Concepts in C++20 are happening and the overlap with the concepts TS is very significant which opens the possibility to write code in a dialect that is accepted by both `-std=c++17 -fconcepts` and `-std=c++2a`. This is a huge bonus for GCC over other implementations, because many long-term supported operating systems ship GCC7 and won't pick up new compilers with full c++20 support for a long time.

The only thing that prevents using the common subset is that concepts are introduced by "concept bool" in the TS, but only by "concept" in the draft standard. Instead of burdening the c++20 implementation with being compatible to the TS, it would be really great if you could change the implementation of the TS on GCC7 and GCC8 to also accept just "concept".

Note that I do not suggest backporting any features or other changes, this is just about a small syntactical change that would allow cleanly writing code that targets older and newer GCC versions at the same time. I assume this would be greatly appreciated by quite a few libraries that currently employ different concept-compatibility layers like range-v3, nanorange, cmstl2 and others. I also expect more people will be interested in targeting the common concepts dialect as Clang is picking up Concepts soon (the c++2a-feature branch works quite well already).
Comment 1 Hannes Hauswedell 2019-04-12 12:12:46 UTC
I see that this has changed for snapshots of GCC9 now, thanks a lot! Is this something you can backport to to GCC7 and GCC8 that would really help downstream projects to reduce needless use of MACROs!

Thanks!
Comment 2 Jonathan Wakely 2019-04-16 10:13:38 UTC
This was changed by Jason in r269692 so let's ask him.

    Don't require 'bool' in a concept definition.
    
            * parser.c (cp_parser_decl_specifier_seq): Support C++20
            concept-definition syntax without 'bool'.
Comment 3 Hannes Hauswedell 2019-08-30 12:52:11 UTC
Any news on this? (I don't know if GCC7 is scheduled to have a patch release at all anymore, but if yes, it would still be great to have this...)
Comment 4 Jonathan Wakely 2019-08-30 13:57:15 UTC
GCC 7 doesn't support the -std=c++2a option, so it doesn't seem necessary to backport it to GCC 7.
Comment 5 Jason Merrill 2019-11-05 11:47:25 UTC
Author: jason
Date: Tue Nov  5 11:46:54 2019
New Revision: 277825

URL: https://gcc.gnu.org/viewcvs?rev=277825&root=gcc&view=rev
Log:
	PR c++/88075 - Don't require 'bool' in a concept definition.

	* parser.c (cp_parser_decl_specifier_seq): Support C++20
	concept-definition syntax without 'bool'.

Added:
    branches/gcc-8-branch/gcc/testsuite/g++.dg/concepts/no-bool1.C
Modified:
    branches/gcc-8-branch/gcc/cp/ChangeLog
    branches/gcc-8-branch/gcc/cp/parser.c
Comment 6 Hannes Hauswedell 2019-11-05 14:24:26 UTC
(In reply to Jason Merrill from comment #5)
> Author: jason
> Date: Tue Nov  5 11:46:54 2019
> New Revision: 277825
> 
> URL: https://gcc.gnu.org/viewcvs?rev=277825&root=gcc&view=rev
> Log:
> 	PR c++/88075 - Don't require 'bool' in a concept definition.
> 
> 	* parser.c (cp_parser_decl_specifier_seq): Support C++20
> 	concept-definition syntax without 'bool'.
> 
> Added:
>     branches/gcc-8-branch/gcc/testsuite/g++.dg/concepts/no-bool1.C
> Modified:
>     branches/gcc-8-branch/gcc/cp/ChangeLog
>     branches/gcc-8-branch/gcc/cp/parser.c


Thanks a lot for this change!

Does this work with -fconcepts and if yes can we also get it for GCC7? Thanks a lot!
Comment 7 Eric Gallager 2019-11-15 03:44:48 UTC
(In reply to Hannes Hauswedell from comment #6)
> (In reply to Jason Merrill from comment #5)
> > Author: jason
> > Date: Tue Nov  5 11:46:54 2019
> > New Revision: 277825
> > 
> > URL: https://gcc.gnu.org/viewcvs?rev=277825&root=gcc&view=rev
> > Log:
> > 	PR c++/88075 - Don't require 'bool' in a concept definition.
> > 
> > 	* parser.c (cp_parser_decl_specifier_seq): Support C++20
> > 	concept-definition syntax without 'bool'.
> > 
> > Added:
> >     branches/gcc-8-branch/gcc/testsuite/g++.dg/concepts/no-bool1.C
> > Modified:
> >     branches/gcc-8-branch/gcc/cp/ChangeLog
> >     branches/gcc-8-branch/gcc/cp/parser.c
> 
> 
> Thanks a lot for this change!
> 
> Does this work with -fconcepts and if yes can we also get it for GCC7?
> Thanks a lot!

Well, the branch for GCC7 just closed, so, looks like not...
Comment 8 Jonathan Wakely 2019-11-16 23:51:27 UTC
Done for 8.4 and 9.1