public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/41508]  New: error: no matching function for call to ...
@ 2009-09-29 18:50 mwarshofsk at aol dot com
  2009-09-29 19:15 ` [Bug c++/41508] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: mwarshofsk at aol dot com @ 2009-09-29 18:50 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2004 bytes --]

I am currently porting an app from Sun Solaris where we use the Solaris cc
compiler (version 5.8). Have a 12 year old legacy app that compiles "fine" in
the current environment :-)

While trying to migrate to RedHat Linux and the GNU g++ compiler (version
4.1.2) I am repeatedly running into "error: no matching function for call to
..." errors with code that sends and/or receives reference parameters.

Here's an example of the compiler error:

EJPeriod.C:102: error: no matching function for call to
âEJPeriod::EJPeriod(Date&, Date&, String)â
EJPeriod.h:83: note: candidates are: EJPeriod::EJPeriod(EJPeriod&)
EJPeriod.h:76: note:                 EJPeriod::EJPeriod()
EJPeriod.h:72: note:                 EJPeriod::EJPeriod(Date, Date, String&)

I don't understand why the compiler doesn't recognize the 3rd constructor
referenced by line 72. When I try to overload the constructor to satisfy the
compiler complaint the compiler correctly tells me the two constructors create
an ambiguous situation. Can you advise as to whether this is a compiler bug or
a potentially old coding standard that isn't acceptable with the version of the
GNU compiler we are using?

Also, this only seems to occur with our "home grown" classes. The compiler has
no issue with basic scalar types and the passing and receiving of reference and
non-reference parameters.

Lastly and admittedly, when I create a simple test.C program to duplicate the
issue the simple example compiles. There must be something else in the 1000s of
lines of code that I am overlooking.

Thanks in advance for any help or direction you can provide.

Regards,
Marc


-- 
           Summary: error: no matching function for call to ...
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mwarshofsk at aol dot com


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


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

* [Bug c++/41508] error: no matching function for call to ...
  2009-09-29 18:50 [Bug c++/41508] New: error: no matching function for call to mwarshofsk at aol dot com
@ 2009-09-29 19:15 ` pinskia at gcc dot gnu dot org
  2009-09-29 19:24 ` mwarshofsk at aol dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-09-29 19:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-09-29 19:15 -------
Can you show the line where the call to EJPeriod::EJPeriod is done?  It might
be because String that you are passing is a rvalue which cannot be bound to
String& as that would mean it needs to be bound to a lvalue.  rvalues can be
bound to const references (or in C++0x rvalue references too).  


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |normal
             Status|UNCONFIRMED                 |WAITING


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


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

* [Bug c++/41508] error: no matching function for call to ...
  2009-09-29 18:50 [Bug c++/41508] New: error: no matching function for call to mwarshofsk at aol dot com
  2009-09-29 19:15 ` [Bug c++/41508] " pinskia at gcc dot gnu dot org
@ 2009-09-29 19:24 ` mwarshofsk at aol dot com
  2009-09-29 19:25 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mwarshofsk at aol dot com @ 2009-09-29 19:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from mwarshofsk at aol dot com  2009-09-29 19:24 -------
This is the method where I am receiving the compiler error:

enum err_stat EJPeriod::rollup( List<EmplJob> &src, List<EJPeriod> &dst,
                                Date &startDt, Date &endDt )
{

// then theres a bunch of code 
// and then the offending line is the one below starting w/EJPeriod

if( srcSize == 1 ) {
    EJPeriod ejptmp( startDt, endDt, src(0)->get_job_title_mgmt_ind() );
    dst.add( new EJPeriod( ejptmp ) );
    return( Success );
   }


The object named "src" is a home grown template linked list class.


-- 


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


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

* [Bug c++/41508] error: no matching function for call to ...
  2009-09-29 18:50 [Bug c++/41508] New: error: no matching function for call to mwarshofsk at aol dot com
  2009-09-29 19:15 ` [Bug c++/41508] " pinskia at gcc dot gnu dot org
  2009-09-29 19:24 ` mwarshofsk at aol dot com
@ 2009-09-29 19:25 ` pinskia at gcc dot gnu dot org
  2009-09-29 19:32 ` mwarshofsk at aol dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-09-29 19:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2009-09-29 19:25 -------
What type does get_job_title_mgmt_ind return?


-- 


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


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

* [Bug c++/41508] error: no matching function for call to ...
  2009-09-29 18:50 [Bug c++/41508] New: error: no matching function for call to mwarshofsk at aol dot com
                   ` (2 preceding siblings ...)
  2009-09-29 19:25 ` pinskia at gcc dot gnu dot org
@ 2009-09-29 19:32 ` mwarshofsk at aol dot com
  2009-09-29 19:41 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mwarshofsk at aol dot com @ 2009-09-29 19:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from mwarshofsk at aol dot com  2009-09-29 19:32 -------
Here's the definition for that call ... I think you're on to something

String get_job_title_mgmt_ind() const { return _jobTitleMgmtInd; };

When I change the constructor to "non reference" paramters it seems to compile
fine. I've got dozens of these to go through. I suspect they're probably all
similar. Is there a better fix than removing the reference parameter? I'm not
really sure why the old code  has it as a reference anyway. The constructor is
not looking to change that value anyway ... its just using it to initialize a
data member.


-- 


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


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

* [Bug c++/41508] error: no matching function for call to ...
  2009-09-29 18:50 [Bug c++/41508] New: error: no matching function for call to mwarshofsk at aol dot com
                   ` (3 preceding siblings ...)
  2009-09-29 19:32 ` mwarshofsk at aol dot com
@ 2009-09-29 19:41 ` pinskia at gcc dot gnu dot org
  2009-09-29 20:08 ` jakub at gcc dot gnu dot org
  2009-09-29 20:34 ` mwarshofsk at aol dot com
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-09-29 19:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2009-09-29 19:41 -------
Yes GCC is correct as in C++ rvalues don't bind to references as only lvalues
bind to references.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug c++/41508] error: no matching function for call to ...
  2009-09-29 18:50 [Bug c++/41508] New: error: no matching function for call to mwarshofsk at aol dot com
                   ` (4 preceding siblings ...)
  2009-09-29 19:41 ` pinskia at gcc dot gnu dot org
@ 2009-09-29 20:08 ` jakub at gcc dot gnu dot org
  2009-09-29 20:34 ` mwarshofsk at aol dot com
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-09-29 20:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jakub at gcc dot gnu dot org  2009-09-29 20:08 -------
If the ctor isn't going to change it, you could as well change the argument
type to const String & instead.


-- 


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


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

* [Bug c++/41508] error: no matching function for call to ...
  2009-09-29 18:50 [Bug c++/41508] New: error: no matching function for call to mwarshofsk at aol dot com
                   ` (5 preceding siblings ...)
  2009-09-29 20:08 ` jakub at gcc dot gnu dot org
@ 2009-09-29 20:34 ` mwarshofsk at aol dot com
  6 siblings, 0 replies; 8+ messages in thread
From: mwarshofsk at aol dot com @ 2009-09-29 20:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from mwarshofsk at aol dot com  2009-09-29 20:34 -------
Comment 6 is perfect! That makes total sense. Thanks so much! Actually, I bet
the Solaris compiler is implicitly treating this same code as a const & String
behind the scenes. We'll just explicitly make that promise/fix for this
migration.  Thanks so much for the speedy and excellent responses!!!


-- 


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


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

end of thread, other threads:[~2009-09-29 20:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-29 18:50 [Bug c++/41508] New: error: no matching function for call to mwarshofsk at aol dot com
2009-09-29 19:15 ` [Bug c++/41508] " pinskia at gcc dot gnu dot org
2009-09-29 19:24 ` mwarshofsk at aol dot com
2009-09-29 19:25 ` pinskia at gcc dot gnu dot org
2009-09-29 19:32 ` mwarshofsk at aol dot com
2009-09-29 19:41 ` pinskia at gcc dot gnu dot org
2009-09-29 20:08 ` jakub at gcc dot gnu dot org
2009-09-29 20:34 ` mwarshofsk at aol dot com

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).