This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/26062] New: "Class object();" is not interpreted as a call to default constructor


The following testcase

#include <iostream>

bool flag = true;
class guardian
{
public:
    guardian() { flag = false; }
    ~guardian() { flag = true; }
    bool get() { return flag; }
};

int main()
{
    guardian guard();
    std::cout << guard.get() << std::endl;
    std::cout << flag << std::endl;
}

Leads to the error
error: request for member 'get' in 'guard', which is of non-class type
'guardian ()()'

Note that it makes guard to *not* being constructed at all, which fails
silently if we don't call any method on the object.

I'm using 
gcc (GCC) 4.0.3 20060115 (prerelease) (Debian 4.0.2-7) on powerpc-linux-gnu


-- 
           Summary: "Class object();" is not interpreted as a call to
                    default constructor
           Product: gcc
           Version: 4.0.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sylvain dot joyeux at m4x dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]