From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20157 invoked by alias); 14 Feb 2003 19:06:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 20143 invoked by uid 71); 14 Feb 2003 19:06:00 -0000 Date: Fri, 14 Feb 2003 19:06:00 -0000 Message-ID: <20030214190600.20142.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: =?ISO-8859-1?Q?Ren=E9_M=F8ller_Fonseca?= Subject: Re: c++/8041: Array to pointer conversion in cast expression Reply-To: =?ISO-8859-1?Q?Ren=E9_M=F8ller_Fonseca?= X-SW-Source: 2003-02/txt/msg00617.txt.bz2 List-Id: The following reply was made to PR c++/8041; it has been noted by GNATS. From: =?ISO-8859-1?Q?Ren=E9_M=F8ller_Fonseca?= To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org, austern@apple.com Cc: Subject: Re: c++/8041: Array to pointer conversion in cast expression Date: Fri, 14 Feb 2003 19:58:47 +0100 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 using namespace std; class MyClass { public: template MyClass(const int (&x)[SIZE]) throw() { cout << "int[" << SIZE << "]" << endl; } template 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; }