public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13446] New: gcc uses cast operator when constructing an unnamed instance
@ 2003-12-19 15:35 erich_guenther at hotmail dot com
2003-12-19 17:40 ` [Bug c++/13446] [3.3/3.4 regression] " bangerth at dealii dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: erich_guenther at hotmail dot com @ 2003-12-19 15:35 UTC (permalink / raw)
To: gcc-bugs
#define FAILS
/* gcc (GCC) 3.3 20030226 (prerelease) (SuSE Linux)
tst.cpp: In constructor `CB::CB()':
tst.cpp:16: error: `SData::operator CDataAccessor&()' is inaccessible
tst.cpp:46: error: within this context
*/
struct CDataAccessor;
// Data layout only
struct SData
{
int m_x;
#ifdef FAILS
operator const CDataAccessor &() const
{
return * reinterpret_cast<const CDataAccessor *>(this);
}
#endif
};
// Accessor class
class CDataAccessor: protected SData
{
public:
explicit CDataAccessor(int i)
{
m_x=i;
};
int Getx() const
{
return m_x;
}
};
class CA
{
public:
CA(int i, const CDataAccessor& x);
};
class CB: public CA
{
public:
CB():CA(2, CDataAccessor(3))
{
};
};
void foo()
{
CB b;
}
--
Summary: gcc uses cast operator when constructing an unnamed
instance
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: erich_guenther at hotmail dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13446
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/13446] [3.3/3.4 regression] gcc uses cast operator when constructing an unnamed instance
2003-12-19 15:35 [Bug c++/13446] New: gcc uses cast operator when constructing an unnamed instance erich_guenther at hotmail dot com
@ 2003-12-19 17:40 ` bangerth at dealii dot org
2003-12-29 18:49 ` pinskia at gcc dot gnu dot org
2004-01-05 21:20 ` mmitchel at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2003-12-19 17:40 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2003-12-19 17:20 -------
Interesting. Here's something smaller:
------------------------
struct S;
struct B {
operator const S &() const;
};
struct S: protected B {
S(int i);
};
void f(int, const S&);
void g()
{
f(2,S(3));
}
---------------------------
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc
x.cc: In function `void g()':
x.cc:4: error: `B::operator const S&() const' is inaccessible
x.cc:15: error: within this context
x.cc:15: error: `B' is not an accessible base of `S'
This is a regression in 3.2/3.3/3.4 w.r.t 2.95.
The point is that gcc tries to convert the S(3) temporary to a const
reference using the conversion operator, rather than directly binding
the temporary.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |rejects-valid
Last reconfirmed|0000-00-00 00:00:00 |2003-12-19 17:20:32
date| |
Summary|gcc uses cast operator when |[3.3/3.4 regression] gcc
|constructing an unnamed |uses cast operator when
|instance |constructing an unnamed
| |instance
Target Milestone|--- |3.3.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13446
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/13446] [3.3/3.4 regression] gcc uses cast operator when constructing an unnamed instance
2003-12-19 15:35 [Bug c++/13446] New: gcc uses cast operator when constructing an unnamed instance erich_guenther at hotmail dot com
2003-12-19 17:40 ` [Bug c++/13446] [3.3/3.4 regression] " bangerth at dealii dot org
@ 2003-12-29 18:49 ` pinskia at gcc dot gnu dot org
2004-01-05 21:20 ` mmitchel at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-29 18:49 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |critical
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13446
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/13446] [3.3/3.4 regression] gcc uses cast operator when constructing an unnamed instance
2003-12-19 15:35 [Bug c++/13446] New: gcc uses cast operator when constructing an unnamed instance erich_guenther at hotmail dot com
2003-12-19 17:40 ` [Bug c++/13446] [3.3/3.4 regression] " bangerth at dealii dot org
2003-12-29 18:49 ` pinskia at gcc dot gnu dot org
@ 2004-01-05 21:20 ` mmitchel at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-01-05 21:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-01-05 21:20 -------
This is not a bug.
[dcl.init.ref] clearly requires that the conversion operator be chosen because
"S(3)" is not an rvalue.
There are no open issues with the commitee about this behavior, but if you think
that this is a defect in the standard you should raise it with the committee.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13446
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-01-05 21:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-19 15:35 [Bug c++/13446] New: gcc uses cast operator when constructing an unnamed instance erich_guenther at hotmail dot com
2003-12-19 17:40 ` [Bug c++/13446] [3.3/3.4 regression] " bangerth at dealii dot org
2003-12-29 18:49 ` pinskia at gcc dot gnu dot org
2004-01-05 21:20 ` mmitchel 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).