public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/34307]  New: when data member name is same as parameter name, possible to omit parameter name in constructor without warning
@ 2007-12-01  4:06 myselfhimself at free dot fr
  2007-12-01 11:33 ` [Bug c++/34307] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: myselfhimself at free dot fr @ 2007-12-01  4:06 UTC (permalink / raw)
  To: gcc-bugs

under Linux 2.6.20, KUbuntu Gutsy with gcc 4.1.3
compiling for use on linux

#if 0

//first here:
//g++ accepts to compile no parameter name is given anytime (not in the class
definition neither in the constructor implementation)
//the program runs ok though
#include <iostream>
using namespace std;

class Hop
{
        public:
                Hop(string);
                void fct(string);

};

Hop::Hop(string)
{}

void Hop::fct(string)
{}

int main()
{
        Hop a("txt");
        return 0;
}
#endif

#if 1

//second: when using an option parameter for constructor
//if we use this parameter name again for member initialisation and it's the
same as a data member name
//this gives no compile pb
//+a crash when running
#include <iostream>
using namespace std;
class Hop
{
        public:
                Hop(string msg="no_msg");
                void sayMsg();
                string msg;
};

Hop::Hop(string):msg(msg)
{}

void Hop::sayMsg()
{
        cout << "msg is:"<<msg<<"-done" <<endl;
}

int main()
{
        Hop a("yo");
        Hop b("");
        a.sayMsg();
        b.sayMsg();
        return 0;
}
#endif


-- 
           Summary: when data member name is same as parameter name,
                    possible to omit parameter name in constructor without
                    warning
           Product: gcc
           Version: 4.1.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: myselfhimself at free dot fr


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-12-04 21:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-01  4:06 [Bug c++/34307] New: when data member name is same as parameter name, possible to omit parameter name in constructor without warning myselfhimself at free dot fr
2007-12-01 11:33 ` [Bug c++/34307] " pinskia at gcc dot gnu dot org
2007-12-04 20:38 ` myselfhimself at free dot fr
2007-12-04 21:04 ` myselfhimself at free dot fr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).