Bug 986134 - Overloading operator issue, occurs when initialization and declaration is on the same line
Summary: Overloading operator issue, occurs when initialization and declaration is on ...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-07-19 03:36 UTC by Brandon
Modified: 2013-07-19 03:40 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2013-07-19 03:40:04 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Brandon 2013-07-19 03:36:36 UTC
Description of problem:

If i overload the operator for a class like the assignment operator. and use it on the same line as declaration of an instance it calls the default operator and not the overloaded one.

using the overloaded operator on a different line works.

ie:

class foo
{
   public:
      foo& operator=(const foo&)
      { do some stuff}
};

////
//in main method//

foo bar = baz;   //default called

bar = baz; // overloaded called.



Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Jakub Jelinek 2013-07-19 03:40:04 UTC
And why do you think this is a bug?
foo bar = baz;
invokes foo (const foo &) constructor rather than assignment operator, please just read the C++ standard.


Note You need to log in before you can comment on or make changes to this bug.