public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115603] New: [concepts] differing declaration and definition do not give error
@ 2024-06-24  2:43 ispavlick at gmail dot com
  0 siblings, 0 replies; only message in thread
From: ispavlick at gmail dot com @ 2024-06-24  2:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115603
           Summary: [concepts] differing declaration and definition do not
                    give error
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ispavlick at gmail dot com
  Target Milestone: ---

#include <vector>
#include <functional>
#include <iostream>


template <typename T>
requires std::is_pointer_v<T>
using stored_not_null = T;

template <int column_cnt>
class Table;

template <int column_cnt>
class Data_with_refresh
{
        Table<column_cnt> *m_table;
public:
        // Declaration does not match with defenition. 
        // stored_not_null<Table<column_cnt>> violates constraint,
        // defeition - does not
        Data_with_refresh(stored_not_null<Table<column_cnt>> *table);
        void fn();
};

template <int column_cnt>
using enter_cb = std::function<void(Data_with_refresh<column_cnt> d)>;

template <int column_cnt>
class Table
{
        enter_cb<column_cnt> m_entercb;
public:
        Table(enter_cb<column_cnt> entercb) {
                m_entercb = std::move(entercb);
                m_entercb(this);
        }
        void refresh() {std::cout << "tick" << std::endl;}
};

// Defenition is different, and does not violates contstraint
template <int column_cnt>
Data_with_refresh<column_cnt>::Data_with_refresh(
                stored_not_null<Table<column_cnt> *> table)
        : m_table(table) {}

template <int column_cnt>
void Data_with_refresh<column_cnt>::fn()
{
        m_table->refresh();
}

int main()
{
        Table<3> tt([](Data_with_refresh<3> dd) {
                        dd.fn();
                });
}

gcc compiles this without errors and warnings, clang gives compile time error

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-06-24  2:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-24  2:43 [Bug c++/115603] New: [concepts] differing declaration and definition do not give error ispavlick at gmail dot com

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).