This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16245] New: Invalid converion of array types.
- From: "vassili_bourdo at softhome dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Jun 2004 13:53:33 -0000
- Subject: [Bug c++/16245] New: Invalid converion of array types.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The code:
-------------------------------------------
typedef char(arr_type)[10];
typedef char(&arr_ref)[10];
arr_ref fn()
{
static arr_type a = {1,2,3,4};
return arr_ref(a);
//return a;
}
-------------------------------------------
Fails to compile on Mingw GCC-3.4.0 with diagnostics:
-------------------------------------------
bug.cxx: In function `char (& fn())[10]':
bug.cxx:7: error: conversion to non-const reference type `char (&)[10]' from
rvalue of type `char*'
bug.cxx:7: error: invalid initialization of non-const reference of type 'char
(&)[10]' from a temporary of type 'char*'
-------------------------------------------
However if replace "return arr_ref(a);" with "return a;" it compiles
--
Summary: Invalid converion of array types.
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: vassili_bourdo at softhome dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16245