[Bug c++/59554] New: Errors with const and volatile in templates.
isak50 at mail dot ru
gcc-bugzilla@gcc.gnu.org
Thu Dec 19 03:21:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59554
Bug ID: 59554
Summary: Errors with const and volatile in templates.
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: isak50 at mail dot ru
Created attachment 31477
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31477&action=edit
source.ii
// templates mis_... don't find out a const and a volatile. Also std tools of
// <type_traits> fail.
// Windows, TDM GCC
#include <stdio.h>
template <typename _Ty>
struct mis_const { static void ch() { printf("is const:
false\n"); } };
template <typename _Ty>
struct mis_const<const _Ty> { static void ch() { printf("is const:
true\n"); } };
template <typename _Ty>
struct mis_volatile { static void ch() { printf("is
volatile: false\n"); } };
template <typename _Ty>
struct mis_volatile<volatile _Ty> { static void ch() { printf("is
volatile: true\n"); } };
template <typename _Ty>
struct mis_pointer { static void ch() { printf("is
pointer: false\n"); } };
template <typename _Ty>
struct mis_pointer<_Ty *> { static void ch() { printf("is
pointer: true\n"); } };
template <typename _T>
void show(_T t)
{
printf("----------_T------------\n");
mis_const<_T>::ch();
mis_volatile<_T>::ch();
mis_pointer<_T>::ch();
printf("------decltype(t)-------\n");
mis_const<decltype(t)>::ch();
mis_volatile<decltype(t)>::ch();
mis_pointer<decltype(t)>::ch();
}
int main()
{
const volatile int *g {nullptr};
show(g);
return 0;
}
// Console output:
// ----------_T------------
// is const: false error: not const.
// is volatile: false error: not volatile.
// is pointer: true It's ok?
// ------decltype(t)-------
// is const: false
// is volatile: false
// is pointer: true
More information about the Gcc-bugs
mailing list