public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16245] New: Invalid converion of array types.
@ 2004-06-28 13:55 vassili_bourdo at softhome dot net
  2004-06-28 13:59 ` [Bug c++/16245] " vassili_bourdo at softhome dot net
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vassili_bourdo at softhome dot net @ 2004-06-28 13:55 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-06-19 15:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-28 13:55 [Bug c++/16245] New: Invalid converion of array types vassili_bourdo at softhome dot net
2004-06-28 13:59 ` [Bug c++/16245] " vassili_bourdo at softhome dot net
2004-06-28 14:19 ` [Bug c++/16245] Arrays decay too quickly bangerth at dealii dot org
2005-06-19 15:05 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).