public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103809] New: spurious reporting of structure redefinition
@ 2021-12-22 18:23 florin at iucha dot net
  2021-12-22 20:42 ` [Bug c++/103809] " redi at gcc dot gnu.org
  2021-12-23 12:55 ` [Bug c++/103809] wrong reporting of (template) struct redefinition when doing a more constrained template outside of the namespace ppalka at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: florin at iucha dot net @ 2021-12-22 18:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103809
           Summary: spurious reporting of structure redefinition
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: florin at iucha dot net
  Target Milestone: ---

Consider the following program:

/*********************************************************/
#include <concepts>

namespace priv
{
    template<typename Value>
    struct Struct {};
}

#ifdef SHOW_BUG

template<std::integral Integral>
struct priv::Struct<Integral> {};

// This way results in:
//  <source>:19:14: error: redefinition of 'struct priv::Struct<Integral>'
//       19 | struct priv::Struct<Float> {};
//          |              ^~~~~~~~~~~~~
template<std::floating_point Float>
struct priv::Struct<Float> {};

#else

namespace priv
{
    template<std::integral Integral>
    struct Struct<Integral> {};

    template<std::floating_point Float>
    struct Struct<Float> {};
}

#endif

int main() {}

/*********************************************************/

Compiling with "g++ -std=c++20 -DSHOW_BUG" results in 

<source>:19:14: error: redefinition of 'struct priv::Struct<Integral>'
   19 | struct priv::Struct<Float> {};
      |              ^~~~~~~~~~~~~
<source>:12:14: note: previous definition of 'struct priv::Struct<Integral>'
   12 | struct priv::Struct<Integral> {};
      |              ^~~~~~~~~~~~~~~~
ASM generation compiler returned: 1
<source>:19:14: error: redefinition of 'struct priv::Struct<Integral>'
   19 | struct priv::Struct<Float> {};
      |              ^~~~~~~~~~~~~
<source>:12:14: note: previous definition of 'struct priv::Struct<Integral>'
   12 | struct priv::Struct<Integral> {};
      |              ^~~~~~~~~~~~~~~~

Compiling without SHOW_BUG results in no error.

(Bug found by my colleague, Ramon Sibello).

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

* [Bug c++/103809] spurious reporting of structure redefinition
  2021-12-22 18:23 [Bug c++/103809] New: spurious reporting of structure redefinition florin at iucha dot net
@ 2021-12-22 20:42 ` redi at gcc dot gnu.org
  2021-12-23 12:55 ` [Bug c++/103809] wrong reporting of (template) struct redefinition when doing a more constrained template outside of the namespace ppalka at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-22 20:42 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-12-22
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
      Known to fail|                            |10.3.0, 11.2.0, 12.0, 9.4.0
           Keywords|                            |rejects-valid

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Confirmed, not a regression.


template<typename T> concept Byte = sizeof(T) == 1;
template<typename T> concept NotByte = sizeof(T) != 1;

namespace priv
{
    template<typename Value>
    struct Struct {};
}

template<Byte T>
struct priv::Struct<T> {};

template<NotByte T>
struct priv::Struct<T> {};


103809.C:14:14: error: redefinition of 'struct priv::Struct<T>'
   14 | struct priv::Struct<T> {};
      |              ^~~~~~~~~
103809.C:11:14: note: previous definition of 'struct priv::Struct<T>'
   11 | struct priv::Struct<T> {};
      |              ^~~~~~~~~

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

* [Bug c++/103809] wrong reporting of (template) struct redefinition when doing a more constrained template outside of the namespace
  2021-12-22 18:23 [Bug c++/103809] New: spurious reporting of structure redefinition florin at iucha dot net
  2021-12-22 20:42 ` [Bug c++/103809] " redi at gcc dot gnu.org
@ 2021-12-23 12:55 ` ppalka at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-12-23 12:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
dup

*** This bug has been marked as a duplicate of bug 92944 ***

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

end of thread, other threads:[~2021-12-23 12:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-22 18:23 [Bug c++/103809] New: spurious reporting of structure redefinition florin at iucha dot net
2021-12-22 20:42 ` [Bug c++/103809] " redi at gcc dot gnu.org
2021-12-23 12:55 ` [Bug c++/103809] wrong reporting of (template) struct redefinition when doing a more constrained template outside of the namespace 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).