public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/41426] New: User defined conversion on return ignores array types
@ 2009-09-21 12:51 roger dot ferrer at bsc dot es
0 siblings, 0 replies; only message in thread
From: roger dot ferrer at bsc dot es @ 2009-09-21 12:51 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1355 bytes --]
I think g++ simplifies too early array types into pointers when looking for a
conversion sequence in a return statement.
---
struct B
{
B (int (&v)[10]);
B();
};
B g2()
{
int c[10];
return c;
}
---
results in
test.cc: In function B g2():
test.cc:10: error: conversion from int* to non-scalar type B requested
while at least the conversion constructor B::B(int (&)[10]) should be given a
chance.
For another (slightly) more elaborated example
---
template <typename _T>
struct A
{
template <int _N>
A(_T (&V)[_N]);
A();
};
A<float> g1()
{
float f[] = {1.1f, 2.3f};
return f;
}
---
which gives
prova.cc: In function A<float> g1():
prova.cc:12: error: conversion from float* to non-scalar type A<float>
requested
Again, at least the 'A<T>::A<_N>(T (&)[_N])' constructor should be given a
chance (which eventually should succeed).
Using an explicit-conversion can be used as workaround.
--
Summary: User defined conversion on return ignores array types
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: roger dot ferrer at bsc dot es
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41426
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-09-21 12:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-21 12:51 [Bug c++/41426] New: User defined conversion on return ignores array types roger dot ferrer at bsc dot es
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).