[Bug c++/81270] [concepts] ill-formed code with a constrained variable declaration with multiple declarators with different deduced types not rejected

2024-04-06 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81270

Andrew Pinski  changed:

   What|Removed |Added

 CC||hewillk at gmail dot com

--- Comment #3 from Andrew Pinski  ---
*** Bug 99925 has been marked as a duplicate of this bug. ***

[Bug c++/81270] [concepts] ill-formed code with a constrained variable declaration with multiple declarators with different deduced types not rejected

2024-04-06 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81270

Andrew Pinski  changed:

   What|Removed |Added

   Last reconfirmed|2019-10-15 00:00:00 |2024-4-6

--- Comment #2 from Andrew Pinski  ---
Without the concept on the auto line GCC correctly rejects it:
```
:3:1: error: inconsistent deduction for 'auto': 'int' and then
'std::nullptr_t'
3 | auto v1 = 1, v2 = nullptr;  // Ill-formed.
  | ^~~~
```

[Bug c++/81270] [concepts] ill-formed code with a constrained variable declaration with multiple declarators with different deduced types not rejected

2019-10-15 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81270

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords||accepts-invalid
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-10-15
 Ever confirmed|0   |1
  Known to fail||10.0

--- Comment #1 from Jonathan Wakely  ---
Still accepted by current trunk.

Also accepted when modernised to C++2a syntax:

template concept C = true;
C auto v1 = 1, v2 = nullptr;  // Ill-formed.
// Following code to demonstrate that the types of v1 and v2 are deduced
// to different types.
template struct is_same {
  static constexpr bool value = false;
};
template struct is_same {
  static constexpr bool value = true;
};
static_assert(is_same::value);
static_assert(is_same::value);