[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-bugs
Subject: Re: c++/8041: Array to pointer conversion in cast expression
From: René_Møller_Fonseca <fonseca () mip ! sdu ! dk>
Date: 2003-02-14 18:58:47
[Download RAW message or body]
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8041
This "implicit casting" problem seems to be related (checked with GCC 3.2 under GNU/Linux and Solaris).
#include <iostream>
using namespace std;
class MyClass {
public:
template<size_t SIZE>
MyClass(const int (&x)[SIZE]) throw() {
cout << "int[" << SIZE << "]" << endl;
}
template<size_t SIZE>
MyClass(long (&x)[SIZE]) throw() {
cout << "long[" << SIZE << "]" << endl;
}
};
MyClass myIntFunction() throw() {
static const int INT_ARRAY[999] = {}; // const
return INT_ARRAY; // this fails to compile
// GCC ERROR: conversion from `const int*' to non-scalar type `MyClass'
}
MyClass myLongFunction() throw() {
static long LONG_ARRAY[1234] = {}; // mutable
return LONG_ARRAY; // this fails to compile
// GCC ERROR: conversion from `long int*' to non-scalar type `MyClass'
}
int main() {
static const int INT_ARRAY[123] = {};
MyClass a(INT_ARRAY); // this works
MyClass b = INT_ARRAY; // this works
myIntFunction();
myLongFunction();
return 0;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic