Bug 986134

Summary: Overloading operator issue, occurs when initialization and declaration is on the same line
Product: [Fedora] Fedora Reporter: Brandon <h_fone>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: jakub, law
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-19 03:40:04 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.