Discussion:
Override/final/noexcept specifiers in templates
(too old to reply)
b***@gmail.com
2018-10-18 09:35:39 UTC
Permalink
Hi,

please consider following example:

namespace test1 {

struct base {};

template<class T>
struct derived : public base {
void foo() override {}
};
}

namespace test2 {

struct base {};

template<class T>
struct derived : public base {
void foo() final {}
};
}

namespace test3 {

struct base {
virtual void foo() noexcept = 0;
virtual ~base() = default;
};

template<typename T>
struct derived : public base {
void foo() override {}
};
}

Above snippet is well formed on g++ but ill-formed on clang with 3
compilation errors:
https://wandbox.org/permlink/78sOlRsl2iEI2oY7

I tried to find information in C++ standard about handling
override/final/noexcept specifiers in templates on and before instantiation
time but without success.
My question is: does above snippet reveals gap in C++ standard or maybe
just misbehaviour in one of compiler?

Regards,
Dawid
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Ville Voutilainen
2018-10-18 09:38:48 UTC
Permalink
Post by b***@gmail.com
Hi,
namespace test1 {
struct base {};
template<class T>
struct derived : public base {
void foo() override {}
};
}
namespace test2 {
struct base {};
template<class T>
struct derived : public base {
void foo() final {}
};
}
namespace test3 {
struct base {
virtual void foo() noexcept = 0;
virtual ~base() = default;
};
template<typename T>
struct derived : public base {
void foo() override {}
};
}
https://wandbox.org/permlink/78sOlRsl2iEI2oY7
I tried to find information in C++ standard about handling override/final/noexcept specifiers in templates on and before instantiation time but without success.
My question is: does above snippet reveals gap in C++ standard or maybe just misbehaviour in one of compiler?
All those test cases are ill-formed, no diagnostic required. Clang
chooses to diagnose them aggressively, GCC chooses not to.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
b***@gmail.com
2018-10-18 10:43:41 UTC
Permalink
Hi,

Ok, thanks for response.
Basing on your response my understanding is that there is no special
treatment for override/final/noexcept in templates and just simple 2 phase
lookup rules applies here, right?
Also if everything is ill-formed it means g++ is wrong?

Regards,
Dawid
Post by b***@gmail.com
Post by b***@gmail.com
Hi,
namespace test1 {
struct base {};
template<class T>
struct derived : public base {
void foo() override {}
};
}
namespace test2 {
struct base {};
template<class T>
struct derived : public base {
void foo() final {}
};
}
namespace test3 {
struct base {
virtual void foo() noexcept = 0;
virtual ~base() = default;
};
template<typename T>
struct derived : public base {
void foo() override {}
};
}
Above snippet is well formed on g++ but ill-formed on clang with 3
https://wandbox.org/permlink/78sOlRsl2iEI2oY7
I tried to find information in C++ standard about handling
override/final/noexcept specifiers in templates on and before instantiation
time but without success.
Post by b***@gmail.com
My question is: does above snippet reveals gap in C++ standard or maybe
just misbehaviour in one of compiler?
All those test cases are ill-formed, no diagnostic required. Clang
chooses to diagnose them aggressively, GCC chooses not to.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Ville Voutilainen
2018-10-18 10:45:49 UTC
Permalink
Post by b***@gmail.com
Hi,
Ok, thanks for response.
Basing on your response my understanding is that there is no special treatment for override/final/noexcept in templates and just simple 2 phase lookup rules applies here, right?
Also if everything is ill-formed it means g++ is wrong?
I said everything is ill-formed, no diagnostic required. g++ is not
required to diagnose that code by the standard, and is specifically
allowed not to diagnose it. The templates can never produce valid
specializations, but the declarations of the member functions
are never instantiated.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
b***@gmail.com
2018-10-18 11:37:22 UTC
Permalink
I simply missed the part saying that no diagnostic is required. Now I get
it. Thanks!
Regards,
Dawid
Post by b***@gmail.com
Post by b***@gmail.com
Hi,
Ok, thanks for response.
Basing on your response my understanding is that there is no special
treatment for override/final/noexcept in templates and just simple 2 phase
lookup rules applies here, right?
Post by b***@gmail.com
Also if everything is ill-formed it means g++ is wrong?
I said everything is ill-formed, no diagnostic required. g++ is not
required to diagnose that code by the standard, and is specifically
allowed not to diagnose it. The templates can never produce valid
specializations, but the declarations of the member functions
are never instantiated.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Continue reading on narkive:
Loading...