Bug 986134 - Overloading operator issue, occurs when initialization and declaration is on the same line
Overloading operator issue, occurs when initialization and declaration is on ...
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-18 23:36 EDT by Brandon
Modified: 2013-07-18 23:40 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-07-18 23:40:04 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Brandon 2013-07-18 23:36:36 EDT
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-18 23:40:04 EDT
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.