Function matching with constructed args

Discussion in 'C++' started by Mike Cote, Jan 22, 2004.

  1. Mike Cote

    Mike Cote Guest

    I have the following function call

    p->f(G());

    where p is a pointer of type P

    and a declaration in scope of

    void P::f(G& g);

    the gcc 3.2 compiler won't match the call to the function.

    If I have

    G gTmp;
    p->f(gTmp);

    with the same function declaration in scope
    everything works.

    Why? 4 other compilers accept it including gcc 2.6.

    Is there a gcc 3.2 option to make this work?
     
    Mike Cote, Jan 22, 2004
    #1
    1. Advertising

  2. Mike Cote

    Ron Natalie Guest

    "Mike Cote" <> wrote in message news:...

    > p->f(G());
    > void P::f(G& g);
    >
    > the gcc 3.2 compiler won't match the call to the function.\


    Of course. G() is an rvalue. You can not bind an rvalue to a (non-const)
    reference. It would match
    void P::f(const G& g);

    > G gTmp;
    > p->f(gTmp);
    >
    > with the same function declaration in scope
    > everything works.


    gTmp is an lvalue.

    > Why? 4 other compilers accept it including gcc 2.6.


    They are broken if they do.
     
    Ron Natalie, Jan 22, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Varn
    Replies:
    2
    Views:
    657
    Ken Varn
    Jun 22, 2005
  2. Replies:
    3
    Views:
    536
    David Eppstein
    Sep 17, 2003
  3. Pierre Fortin

    args v. *args passed to: os.path.join()

    Pierre Fortin, Sep 18, 2004, in forum: Python
    Replies:
    2
    Views:
    745
    Pierre Fortin
    Sep 18, 2004
  4. er
    Replies:
    2
    Views:
    541
  5. Andrew Tomazos
    Replies:
    5
    Views:
    630
Loading...

Share This Page