http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53753

             Bug #: 53753
           Summary: stack based constructor is not called for  Class1
                    Object1()
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: kiran.put...@gmail.com


I have gcc version 4.7.0 (Ubuntu/Linaro 4.7.0-7ubuntu3) I have following
program

#include<iostream>
class Myclass
{
public:
       Myclass() {
        std::cout<<"Value of mInt : "<< mInt << " value mStr : " << mStr
<<std::endl;
        std::cout<<"test complete" << std::endl;
        }
protected:
        int mInt;
        std::string mStr;
};

int main(void)
{
        Myclass instance1();
        return 0;
}

if I compile the program with following options
#g++ -W -Wall -Wextra -pedantic -std=c++0x -c inclass-member-initialize.cpp -o
inclass-member-initialize.o
#g++  inclass-member-initialize.o -o output

and If I run the output program 
#output
It doesn't show constructor initialization statement at all

But if i modify the line as
             Myclass instance1 = Myclass();

Then the constructor is getting called, and I can see test messages.

Even constructor on heap also shows up without any issues such as
             Myclass *instance1 = new Myclass();

works just fine,

Just the intialization like Myclass instance1() is currently having issues

Is this expected ?

Reply via email to