public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13478] New: gcc uses wrong constructor to initialize a const reference
@ 2003-12-23 14:53 erich_guenther at hotmail dot com
2003-12-23 18:22 ` [Bug c++/13478] " pinskia at gcc dot gnu dot org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: erich_guenther at hotmail dot com @ 2003-12-23 14:53 UTC (permalink / raw)
To: gcc-bugs
#define FAILS
/* gcc (GCC) 3.3 20030226 (prerelease) (SuSE Linux)
tzst2.cpp: In function `void foo(const SA*)':
tzst2.cpp:29: error: `CA::CA(const CA&)' is private
tzst2.cpp:34: error: within this context
tzst2.cpp:34: error: initializing temporary from result of `CA::CA(const SA&)
*/
// Data layout only
struct SA
{
};
class CA :protected SA
{
public:
CA()
{
};
CA(const SA& a)
{
};
#ifdef FAILS
private:
CA(const CA& a);
#endif
};
void foo(const SA * pa)
{
const CA& ra=*pa;
}
--
Summary: gcc uses wrong constructor to initialize a const
reference
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
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/13478] gcc uses wrong constructor to initialize a const reference
2003-12-23 14:53 [Bug c++/13478] New: gcc uses wrong constructor to initialize a const reference erich_guenther at hotmail dot com
@ 2003-12-23 18:22 ` pinskia at gcc dot gnu dot org
2003-12-24 2:55 ` giovannibajo at libero dot it
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-23 18:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2003-12-23 18:13 -------
The error is right you have to an accessorable copy constructor when initing a variable.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/13478] gcc uses wrong constructor to initialize a const reference
2003-12-23 14:53 [Bug c++/13478] New: gcc uses wrong constructor to initialize a const reference erich_guenther at hotmail dot com
2003-12-23 18:22 ` [Bug c++/13478] " pinskia at gcc dot gnu dot org
@ 2003-12-24 2:55 ` giovannibajo at libero dot it
2003-12-24 4:16 ` giovannibajo at libero dot it
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: giovannibajo at libero dot it @ 2003-12-24 2:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2003-12-24 02:40 -------
That's not a variable, it's a reference. GCC should not call any constructor
when binding the variable to that reference.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/13478] gcc uses wrong constructor to initialize a const reference
2003-12-23 14:53 [Bug c++/13478] New: gcc uses wrong constructor to initialize a const reference erich_guenther at hotmail dot com
2003-12-23 18:22 ` [Bug c++/13478] " pinskia at gcc dot gnu dot org
2003-12-24 2:55 ` giovannibajo at libero dot it
@ 2003-12-24 4:16 ` giovannibajo at libero dot it
2004-01-11 12:24 ` [Bug c++/13478] [3.3/3.4 Regression] " giovannibajo at libero dot it
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: giovannibajo at libero dot it @ 2003-12-24 4:16 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2003-12-24 02:55 -------
Uhm, ok, it must call a copy constructor, but the first one.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/13478] [3.3/3.4 Regression] gcc uses wrong constructor to initialize a const reference
2003-12-23 14:53 [Bug c++/13478] New: gcc uses wrong constructor to initialize a const reference erich_guenther at hotmail dot com
` (2 preceding siblings ...)
2003-12-24 4:16 ` giovannibajo at libero dot it
@ 2004-01-11 12:24 ` giovannibajo at libero dot it
2004-01-15 5:36 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: giovannibajo at libero dot it @ 2004-01-11 12:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-01-11 12:24 -------
Ok. Given:
------------------------------------
struct A {};
struct B : protected A {
B() {};
B(const A& ) {};
private:
B(const B& ) {};
};
void foo(const A* ap)
{
const B& br = *ap;
}
------------------------------------
The code should compile, because it should call B(const A&) to construct the
temporary which is then bound to the const reference. Instead, GCC seems to
call B(const B&), which is private. I can't test on 3.0/3.1, but it's surely a
regression since 3.0.4, and can be made a wrong-code one if we make the
constructor public. I keep it as rejects-valid as it's easier to debug.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |giovannibajo at libero dot
| |it
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |rejects-valid
Last reconfirmed|0000-00-00 00:00:00 |2004-01-11 12:24:53
date| |
Summary|gcc uses wrong constructor |[3.3/3.4 Regression] gcc
|to initialize a const |uses wrong constructor to
|reference |initialize a const reference
Target Milestone|--- |3.4.0
Version|3.3 |3.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/13478] [3.3/3.4 Regression] gcc uses wrong constructor to initialize a const reference
2003-12-23 14:53 [Bug c++/13478] New: gcc uses wrong constructor to initialize a const reference erich_guenther at hotmail dot com
` (3 preceding siblings ...)
2004-01-11 12:24 ` [Bug c++/13478] [3.3/3.4 Regression] " giovannibajo at libero dot it
@ 2004-01-15 5:36 ` pinskia at gcc dot gnu dot org
2004-01-16 16:59 ` cvs-commit at gcc dot gnu dot org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-15 5:36 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-01-15 05:36 -------
Failing since at least 2000-12-31.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/13478] [3.3/3.4 Regression] gcc uses wrong constructor to initialize a const reference
2003-12-23 14:53 [Bug c++/13478] New: gcc uses wrong constructor to initialize a const reference erich_guenther at hotmail dot com
` (4 preceding siblings ...)
2004-01-15 5:36 ` pinskia at gcc dot gnu dot org
@ 2004-01-16 16:59 ` cvs-commit at gcc dot gnu dot org
2004-01-16 17:54 ` cvs-commit at gcc dot gnu dot org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-01-16 16:59 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-01-16 16:59 -------
Subject: Bug 13478
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: mmitchel@gcc.gnu.org 2004-01-16 16:59:30
Modified files:
gcc/cp : ChangeLog call.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/init: ref10.C
Log message:
PR c++/13478
* call.c (convert_like_real): Do not perform an additional
direct-initialization when binding to a reference.
PR c++/13478
* g++.dg/init/ref10.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3887&r2=1.3888
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.449&r2=1.450
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3384&r2=1.3385
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/ref10.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/13478] [3.3/3.4 Regression] gcc uses wrong constructor to initialize a const reference
2003-12-23 14:53 [Bug c++/13478] New: gcc uses wrong constructor to initialize a const reference erich_guenther at hotmail dot com
` (5 preceding siblings ...)
2004-01-16 16:59 ` cvs-commit at gcc dot gnu dot org
@ 2004-01-16 17:54 ` cvs-commit at gcc dot gnu dot org
2004-01-16 17:57 ` [Bug c++/13478] [3.3 " mmitchel at gcc dot gnu dot org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-01-16 17:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-01-16 17:54 -------
Subject: Bug 13478
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: mmitchel@gcc.gnu.org 2004-01-16 17:54:25
Modified files:
gcc/cp : ChangeLog call.c
Log message:
PR c++/13478
* call.c (initialize_reference): Pass -1 for inner parameter to
convert_like_real.
PR c++/13478
* g++.dg/init/ref10.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3888&r2=1.3889
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.450&r2=1.451
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/13478] [3.3 Regression] gcc uses wrong constructor to initialize a const reference
2003-12-23 14:53 [Bug c++/13478] New: gcc uses wrong constructor to initialize a const reference erich_guenther at hotmail dot com
` (6 preceding siblings ...)
2004-01-16 17:54 ` cvs-commit at gcc dot gnu dot org
@ 2004-01-16 17:57 ` mmitchel at gcc dot gnu dot org
2004-01-20 16:48 ` bangerth at dealii dot org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-01-16 17:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-01-16 17:57 -------
Fixed in GCC 3.4.
--
What |Removed |Added
----------------------------------------------------------------------------
Summary|[3.3/3.4 Regression] gcc |[3.3 Regression] gcc uses
|uses wrong constructor to |wrong constructor to
|initialize a const reference|initialize a const reference
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/13478] [3.3 Regression] gcc uses wrong constructor to initialize a const reference
2003-12-23 14:53 [Bug c++/13478] New: gcc uses wrong constructor to initialize a const reference erich_guenther at hotmail dot com
` (7 preceding siblings ...)
2004-01-16 17:57 ` [Bug c++/13478] [3.3 " mmitchel at gcc dot gnu dot org
@ 2004-01-20 16:48 ` bangerth at dealii dot org
2004-01-21 7:30 ` cvs-commit at gcc dot gnu dot org
2004-01-21 7:31 ` gdr at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2004-01-20 16:48 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.4.0 |3.3.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/13478] [3.3 Regression] gcc uses wrong constructor to initialize a const reference
2003-12-23 14:53 [Bug c++/13478] New: gcc uses wrong constructor to initialize a const reference erich_guenther at hotmail dot com
` (8 preceding siblings ...)
2004-01-20 16:48 ` bangerth at dealii dot org
@ 2004-01-21 7:30 ` cvs-commit at gcc dot gnu dot org
2004-01-21 7:31 ` gdr at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-01-21 7:30 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-01-21 07:30 -------
Subject: Bug 13478
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_3-branch
Changes by: gdr@gcc.gnu.org 2004-01-21 07:30:07
Modified files:
gcc/cp : ChangeLog call.c
Added files:
gcc/testsuite/g++.dg/init: ref10.C
Log message:
Backport from mainline
2004-01-16 Mark Mitchell <mark@codesourcery.com>
PR c++/13478
* call.c (initialize_reference): Pass -1 for inner parameter to
convert_like_real.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.240&r2=1.3076.2.241
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.341.2.35&r2=1.341.2.36
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/ref10.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.6.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/13478] [3.3 Regression] gcc uses wrong constructor to initialize a const reference
2003-12-23 14:53 [Bug c++/13478] New: gcc uses wrong constructor to initialize a const reference erich_guenther at hotmail dot com
` (9 preceding siblings ...)
2004-01-21 7:30 ` cvs-commit at gcc dot gnu dot org
@ 2004-01-21 7:31 ` gdr at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: gdr at gcc dot gnu dot org @ 2004-01-21 7:31 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at gcc dot gnu dot org 2004-01-21 07:31 -------
Fixed with a backport from mainline.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2004-01-21 7:31 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-23 14:53 [Bug c++/13478] New: gcc uses wrong constructor to initialize a const reference erich_guenther at hotmail dot com
2003-12-23 18:22 ` [Bug c++/13478] " pinskia at gcc dot gnu dot org
2003-12-24 2:55 ` giovannibajo at libero dot it
2003-12-24 4:16 ` giovannibajo at libero dot it
2004-01-11 12:24 ` [Bug c++/13478] [3.3/3.4 Regression] " giovannibajo at libero dot it
2004-01-15 5:36 ` pinskia at gcc dot gnu dot org
2004-01-16 16:59 ` cvs-commit at gcc dot gnu dot org
2004-01-16 17:54 ` cvs-commit at gcc dot gnu dot org
2004-01-16 17:57 ` [Bug c++/13478] [3.3 " mmitchel at gcc dot gnu dot org
2004-01-20 16:48 ` bangerth at dealii dot org
2004-01-21 7:30 ` cvs-commit at gcc dot gnu dot org
2004-01-21 7:31 ` gdr 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).