public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94186] New: compiler incorrectly accepts a requires clause with predicate of non-bool type
@ 2020-03-15 22:43 akrzemi1 at gmail dot com
  2020-03-16 10:53 ` [Bug c++/94186] " marxin at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: akrzemi1 at gmail dot com @ 2020-03-15 22:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94186
           Summary: compiler incorrectly accepts a requires clause with
                    predicate of non-bool type
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: akrzemi1 at gmail dot com
  Target Milestone: ---

The following program should fail to compile in C++20 because the type of the
predicate in requires-clause is not bool. 

```
template <typename T>
struct is_small
{
  enum { value = sizeof(T) <= 4 };
};

template <typename T>
  requires is_small<T>::value
void fun(T) {} 

template <typename T>
void fun(T) {} 

int main()
{
  fun(1);  // expected hard compiler error
}
```

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

* [Bug c++/94186] compiler incorrectly accepts a requires clause with predicate of non-bool type
  2020-03-15 22:43 [Bug c++/94186] New: compiler incorrectly accepts a requires clause with predicate of non-bool type akrzemi1 at gmail dot com
@ 2020-03-16 10:53 ` marxin at gcc dot gnu.org
  2020-03-17  4:10 ` [Bug c++/94186] [10 Regression] " jason at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-03-16 10:53 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-03-16

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started to be accepted with r10-3735-gcb57504a55015891.

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

* [Bug c++/94186] [10 Regression] compiler incorrectly accepts a requires clause with predicate of non-bool type
  2020-03-15 22:43 [Bug c++/94186] New: compiler incorrectly accepts a requires clause with predicate of non-bool type akrzemi1 at gmail dot com
  2020-03-16 10:53 ` [Bug c++/94186] " marxin at gcc dot gnu.org
@ 2020-03-17  4:10 ` jason at gcc dot gnu.org
  2020-03-17 10:58 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2020-03-17  4:10 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrew.n.sutton at gmail dot com

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Andrew, thoughts?

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

* [Bug c++/94186] [10 Regression] compiler incorrectly accepts a requires clause with predicate of non-bool type
  2020-03-15 22:43 [Bug c++/94186] New: compiler incorrectly accepts a requires clause with predicate of non-bool type akrzemi1 at gmail dot com
  2020-03-16 10:53 ` [Bug c++/94186] " marxin at gcc dot gnu.org
  2020-03-17  4:10 ` [Bug c++/94186] [10 Regression] " jason at gcc dot gnu.org
@ 2020-03-17 10:58 ` paolo.carlini at oracle dot com
  2020-03-17 14:16 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2020-03-17 10:58 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paolo.carlini at oracle dot com

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Isn't this fixable by simply tweaking satisfy_atom to unconditionally issue the
error?

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

* [Bug c++/94186] [10 Regression] compiler incorrectly accepts a requires clause with predicate of non-bool type
  2020-03-15 22:43 [Bug c++/94186] New: compiler incorrectly accepts a requires clause with predicate of non-bool type akrzemi1 at gmail dot com
                   ` (2 preceding siblings ...)
  2020-03-17 10:58 ` paolo.carlini at oracle dot com
@ 2020-03-17 14:16 ` paolo.carlini at oracle dot com
  2020-03-20  4:13 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2020-03-17 14:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
To wit:

diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 697ed6726b8..59b43a31274 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -2543,8 +2543,7 @@ satisfy_atom (tree t, tree args, subst_info info)
     return cache.save (error_mark_node);
   if (!same_type_p (TREE_TYPE (result), boolean_type_node))
     {
-      if (info.noisy ())
-       error_at (loc, "constraint does not have type %<bool%>");
+      error_at (loc, "constraint does not have type %<bool%>");
       return cache.save (error_mark_node);
     }

passes testing. Since currently we don't have an accurate location for the
constraint we could also pretty print it with %qE (ie, what we did in 9).

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

* [Bug c++/94186] [10 Regression] compiler incorrectly accepts a requires clause with predicate of non-bool type
  2020-03-15 22:43 [Bug c++/94186] New: compiler incorrectly accepts a requires clause with predicate of non-bool type akrzemi1 at gmail dot com
                   ` (3 preceding siblings ...)
  2020-03-17 14:16 ` paolo.carlini at oracle dot com
@ 2020-03-20  4:13 ` jason at gcc dot gnu.org
  2020-03-20 11:46 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2020-03-20  4:13 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
   Target Milestone|---                         |10.0
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org

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

* [Bug c++/94186] [10 Regression] compiler incorrectly accepts a requires clause with predicate of non-bool type
  2020-03-15 22:43 [Bug c++/94186] New: compiler incorrectly accepts a requires clause with predicate of non-bool type akrzemi1 at gmail dot com
                   ` (4 preceding siblings ...)
  2020-03-20  4:13 ` jason at gcc dot gnu.org
@ 2020-03-20 11:46 ` rguenth at gcc dot gnu.org
  2020-03-24 22:25 ` cvs-commit at gcc dot gnu.org
  2020-03-24 22:26 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-03-20 11:46 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

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

* [Bug c++/94186] [10 Regression] compiler incorrectly accepts a requires clause with predicate of non-bool type
  2020-03-15 22:43 [Bug c++/94186] New: compiler incorrectly accepts a requires clause with predicate of non-bool type akrzemi1 at gmail dot com
                   ` (5 preceding siblings ...)
  2020-03-20 11:46 ` rguenth at gcc dot gnu.org
@ 2020-03-24 22:25 ` cvs-commit at gcc dot gnu.org
  2020-03-24 22:26 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-03-24 22:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:fddfd3ce555965864b6116cf541f6355d2057d3d

commit r10-7361-gfddfd3ce555965864b6116cf541f6355d2057d3d
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Mar 24 18:25:17 2020 -0400

    c++: Improve handling of ill-formed constraints [PR94186].

    It would have been trivial to make the error for non-bool constraint in
    satisfy_atom unconditional, but that didn't give context for the error or
    printing with the dependent form and template arguments.  So I changed a
    couple of places so that, when a hard error is encountered during quiet
    substitution/satisfaction, we go through again noisily; this builds up the
    necessary context.

    The similar change to tsubst_nested_requirement does not build up the
    necessary context; rather than try to fix that now I changed
    get_constraint_error_location to give up and use input_location if there's
    no CONSTR_CONTEXT.  In the case of concepts-pr67697.C, we still have a good
    source location because the NESTED_REQ has a correct EXPR_LOCATION, but
this
    patch doesn't improve context printing for this case as it does for the
    above.

    gcc/cp/ChangeLog
    2020-03-24  Jason Merrill  <jason@redhat.com>

            PR c++/94186
            * constraint.cc (constraint_satisfaction_value): Repeat noisily on
            error.
            (tsubst_nested_requirement): Likewise.
            (get_constraint_error_location): Allow missing context.
            (diagnose_atomic_constraint): Diagnose non-bool constraint here.
            (satisfy_atom): Not here.  Only diagnose non-constant when noisy.

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

* [Bug c++/94186] [10 Regression] compiler incorrectly accepts a requires clause with predicate of non-bool type
  2020-03-15 22:43 [Bug c++/94186] New: compiler incorrectly accepts a requires clause with predicate of non-bool type akrzemi1 at gmail dot com
                   ` (6 preceding siblings ...)
  2020-03-24 22:25 ` cvs-commit at gcc dot gnu.org
@ 2020-03-24 22:26 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2020-03-24 22:26 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Paolo Carlini from comment #3)
> Isn't this fixable by simply tweaking satisfy_atom to unconditionally issue
> the error?

Yes, but I thought we could do better. :)

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

end of thread, other threads:[~2020-03-24 22:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-15 22:43 [Bug c++/94186] New: compiler incorrectly accepts a requires clause with predicate of non-bool type akrzemi1 at gmail dot com
2020-03-16 10:53 ` [Bug c++/94186] " marxin at gcc dot gnu.org
2020-03-17  4:10 ` [Bug c++/94186] [10 Regression] " jason at gcc dot gnu.org
2020-03-17 10:58 ` paolo.carlini at oracle dot com
2020-03-17 14:16 ` paolo.carlini at oracle dot com
2020-03-20  4:13 ` jason at gcc dot gnu.org
2020-03-20 11:46 ` rguenth at gcc dot gnu.org
2020-03-24 22:25 ` cvs-commit at gcc dot gnu.org
2020-03-24 22:26 ` jason 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).