public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "giovannibajo at libero dot it" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/14140] [3.3/3.4/4.0 Regression] Unwanted call to derived constructor after implicit conversion
Date: Wed, 13 Oct 2004 14:21:00 -0000	[thread overview]
Message-ID: <20041013142118.30374.qmail@sourceware.org> (raw)
In-Reply-To: <20040213140825.14140.christian.engstrom@glindra.org>


------- 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


  parent reply	other threads:[~2004-10-13 14:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-13 14:08 [Bug c++/14140] New: " 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
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
2004-10-13 14:21 ` giovannibajo at libero dot it [this message]
2004-10-13 14:25 ` [Bug c++/14140] [3.3/3.4/4.0 Regression] " giovannibajo at libero dot it
2004-10-13 14:59 ` pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041013142118.30374.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).