* [Bug c++/14140] Unwanted call to derived constructor after implicit conversion
2004-02-13 14:08 [Bug c++/14140] New: Unwanted call to derived constructor after implicit conversion christian dot engstrom at glindra dot org
@ 2004-02-13 14:36 ` gcc-bugs at michaelmellor dot com
2004-02-13 14:55 ` pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: gcc-bugs at michaelmellor dot com @ 2004-02-13 14:36 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |gcc-bugs at michaelmellor
| |dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14140
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/14140] Unwanted call to derived constructor after implicit conversion
2004-02-13 14:08 [Bug c++/14140] New: Unwanted call to derived constructor after implicit conversion christian dot engstrom at glindra dot org
2004-02-13 14:36 ` [Bug c++/14140] " gcc-bugs at michaelmellor dot com
@ 2004-02-13 14:55 ` pinskia at gcc dot gnu dot org
2004-02-14 20:11 ` pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-02-13 14:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-02-13 14:55 -------
ICC 6.0 just calls derived::derived(derived const&) instead base::base(base const&).
I do not know who is right now.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14140
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/14140] Unwanted call to derived constructor after implicit conversion
2004-02-13 14:08 [Bug c++/14140] New: Unwanted call to derived constructor after implicit conversion christian dot engstrom at glindra dot org
2004-02-13 14:36 ` [Bug c++/14140] " gcc-bugs at michaelmellor dot com
2004-02-13 14:55 ` pinskia at gcc dot gnu dot org
@ 2004-02-14 20:11 ` pinskia at gcc dot gnu dot org
2004-02-28 14:52 ` giovannibajo at libero dot it
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-02-14 20:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-02-14 20:11 -------
Confirmed, related to 14035.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |rejects-valid, wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2004-02-14 20:11:43
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14140
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/14140] Unwanted call to derived constructor after implicit conversion
2004-02-13 14:08 [Bug c++/14140] New: Unwanted call to derived constructor after implicit conversion christian dot engstrom at glindra dot org
` (2 preceding siblings ...)
2004-02-14 20:11 ` pinskia at gcc dot gnu dot org
@ 2004-02-28 14:52 ` giovannibajo at libero dot it
2004-04-28 3:40 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: giovannibajo at libero dot it @ 2004-02-28 14:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-02-28 14:52 -------
I don't see any reason why the derived copy constructor should be called. I
also double-checked with MSVC71 and Comeau 4.3.3 (which uses the latest EDG),
and they both agree that only the base constructor should be called.
It looks like the conversion operator is responsible for this behaviour, and
calls the copy constructor withour realizing the operator* returns the same
type.
Can anybody check if this is a regression? I don't have anything older than 3.2
(and yes, I should really rebuild those).
--
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |3.3.3 3.2.3 3.4.0 3.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14140
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/14140] Unwanted call to derived constructor after implicit conversion
2004-02-13 14:08 [Bug c++/14140] New: Unwanted call to derived constructor after implicit conversion christian dot engstrom at glindra dot org
` (3 preceding siblings ...)
2004-02-28 14:52 ` giovannibajo at libero dot it
@ 2004-04-28 3:40 ` pinskia at gcc dot gnu dot org
2004-04-28 11:30 ` giovannibajo at libero dot it
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-28 3:40 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-04-28 02:06 -------
Well I made the derived copy construtor private and I noticed that ICC errors out that the
copy construtor is inaccessible.
pr14140.cc
pr14140.cc(56): error #373: "derived::derived(const derived &)" is inaccessible
func((d_handle)); // Calls 'derived' copy constructor with gcc (only)
^
pr14140.cc(56): error #373: "derived::derived(const derived &)" is inaccessible
func((d_handle)); // Calls 'derived' copy constructor with gcc (only)
^
compilation aborted for pr14140.cc (code 2)
GCC does the thing, so this is not wrong-code at all as it is allowed by the standard to
call the copy construtor here.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14140
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/14140] Unwanted call to derived constructor after implicit conversion
2004-02-13 14:08 [Bug c++/14140] New: Unwanted call to derived constructor after implicit conversion christian dot engstrom at glindra dot org
` (4 preceding siblings ...)
2004-04-28 3:40 ` pinskia at gcc dot gnu dot org
@ 2004-04-28 11:30 ` giovannibajo at libero dot it
2004-10-13 13:40 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: giovannibajo at libero dot it @ 2004-04-28 11:30 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-04-28 11:22 -------
No, this *is* a bug. I already analyzed this, Andrew.
Try adding this:
derived& convert() const { return **this;}
to derived_handle, and using it instead of relying on the implicit conversion.
You will see that the call to derived construction is gone.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14140
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/14140] Unwanted call to derived constructor after implicit conversion
2004-02-13 14:08 [Bug c++/14140] New: Unwanted call to derived constructor after implicit conversion christian dot engstrom at glindra dot org
` (5 preceding siblings ...)
2004-04-28 11:30 ` giovannibajo at libero dot it
@ 2004-10-13 13:40 ` pinskia at gcc dot gnu dot org
2004-10-13 14:21 ` [Bug c++/14140] [3.3/3.4/4.0 Regression] " giovannibajo at libero dot it
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-13 13:40 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |NEW
Known to fail|3.3.3 3.2.3 3.4.0 4.0 |3.3.3 3.2.3 3.4.0 4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14140
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/14140] [3.3/3.4/4.0 Regression] Unwanted call to derived constructor after implicit conversion
2004-02-13 14:08 [Bug c++/14140] New: Unwanted call to derived constructor after implicit conversion christian dot engstrom at glindra dot org
` (6 preceding siblings ...)
2004-10-13 13:40 ` pinskia at gcc dot gnu dot org
@ 2004-10-13 14:21 ` giovannibajo at libero dot it
2004-10-13 14:25 ` giovannibajo at libero dot it
2004-10-13 14:59 ` pinskia at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-13 14:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-10-13 14:21 -------
Slightly cleaned-up testcase:
--------------------------------------------------
extern "C" int printf(const char* fmt, ...);
extern "C" void abort(void);
struct A {
A() {}
A(const A&) { printf("A cctor\n"); }
};
struct B : public A {
B() {}
B(const B&) { printf("B cctor\n"); abort(); }
};
struct Wrapper
{
B* b;
Wrapper(B* b_) : b(b_) {}
B& operator*() const {return *b;}
operator B&() const {return **this;}
};
void func(A a) {} // Takes the parameter by value
int main()
{
B b;
Wrapper b_wrap(&b);
printf("\nCalling 'func(b)':\n");
func(b);
printf("\nCalling 'func(*b_wrap)':\n");
func(*b_wrap);
printf("\nCalling 'func(b_wrap)':\n");
func(b_wrap);
return 0;
}
--------------------------------------------------
In short, this should not abort, and does not with ICC, Comeau, or MSVC. This
is a regression since 2.95 appeared with 3.0.
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |critical
Known to fail|3.3.3 3.2.3 3.4.0 4.0.0 |3.0.4 3.3.3 3.2.3 3.4.0
| |4.0.0
Known to work| |2.95.3
Summary|Unwanted call to derived |[3.3/3.4/4.0 Regression]
|constructor after implicit |Unwanted call to derived
|conversion |constructor after implicit
| |conversion
Target Milestone|--- |3.4.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14140
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/14140] [3.3/3.4/4.0 Regression] Unwanted call to derived constructor after implicit conversion
2004-02-13 14:08 [Bug c++/14140] New: Unwanted call to derived constructor after implicit conversion christian dot engstrom at glindra dot org
` (7 preceding siblings ...)
2004-10-13 14:21 ` [Bug c++/14140] [3.3/3.4/4.0 Regression] " giovannibajo at libero dot it
@ 2004-10-13 14:25 ` giovannibajo at libero dot it
2004-10-13 14:59 ` pinskia at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-13 14:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-10-13 14:25 -------
The original thread (with some C++ standard reference) is here:
http://tinyurl.com/5smcv
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14140
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/14140] [3.3/3.4/4.0 Regression] Unwanted call to derived constructor after implicit conversion
2004-02-13 14:08 [Bug c++/14140] New: Unwanted call to derived constructor after implicit conversion christian dot engstrom at glindra dot org
` (8 preceding siblings ...)
2004-10-13 14:25 ` giovannibajo at libero dot it
@ 2004-10-13 14:59 ` pinskia at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-13 14:59 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-10-13 14:59 -------
Then this is a dup of bug 14035.
*** This bug has been marked as a duplicate of 14035 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14140
^ permalink raw reply [flat|nested] 11+ messages in thread