gcc warnings

Discussion in 'C++' started by asdf, Jun 26, 2006.

  1. asdf

    asdf Guest

    Dear all,

    The following coding have two warnings in GCC, could you please figure
    it out for me? Thank you very much !

    602 : EdgePair *p1, *p2, *p3;
    603 :
    604 : //
    605 : if (ES_sanityCheck(e1,e2))
    606 : p1 = new EdgePair(e1, e2);
    607 : if (ES_sanityCheck(e2,e3))
    608 : p2 = new EdgePair(e2, e3);
    609 : if (ES_sanityCheck(e1,e3))
    610 : p3 = new EdgePair(e1, e3);
    611 :
    612 : //
    613 : //
    614 : if (p1 && p2 && p3){
    615 : bool ret = ES_sanityCheck(p1, p2) &&
    616 : ES_sanityCheck(p1, p3) &&
    617 : ES_sanityCheck(p2, p3);
    618 :
    619 : delete p1, p2, p3;
    620 : return ret;
    621 : }


    619: warning: right-hand operand of comma has no effect
    619: warning: right-hand operand of comma has no effect
     
    asdf, Jun 26, 2006
    #1
    1. Advertising

  2. asdf

    Jim Langston Guest

    "asdf" <> wrote in message
    news:...
    > Dear all,
    >
    > The following coding have two warnings in GCC, could you please figure
    > it out for me? Thank you very much !
    >
    > 602 : EdgePair *p1, *p2, *p3;
    > 603 :
    > 604 : //
    > 605 : if (ES_sanityCheck(e1,e2))
    > 606 : p1 = new EdgePair(e1, e2);
    > 607 : if (ES_sanityCheck(e2,e3))
    > 608 : p2 = new EdgePair(e2, e3);
    > 609 : if (ES_sanityCheck(e1,e3))
    > 610 : p3 = new EdgePair(e1, e3);
    > 611 :
    > 612 : //
    > 613 : //
    > 614 : if (p1 && p2 && p3){
    > 615 : bool ret = ES_sanityCheck(p1, p2) &&
    > 616 : ES_sanityCheck(p1, p3) &&
    > 617 : ES_sanityCheck(p2, p3);
    > 618 :
    > 619 : delete p1, p2, p3;


    delete p1;
    delete p2;
    delete p3;

    or

    delete p1, delete p2, delete p3;

    Otherwise p2 is just doing nothing whatsoever.

    > 620 : return ret;
    > 621 : }
    >
    >
    > 619: warning: right-hand operand of comma has no effect
    > 619: warning: right-hand operand of comma has no effect
    >
     
    Jim Langston, Jun 26, 2006
    #2
    1. Advertising

  3. asdf

    Jerry Coffin Guest

    In article <>,
    says...

    [ ... ]

    > 619 : delete p1, p2, p3;
    > 620 : return ret;
    > 621 : }
    >
    >
    > 619: warning: right-hand operand of comma has no effect
    > 619: warning: right-hand operand of comma has no effect


    The delete expression takes only one operand, so to delete all three
    of these, you need:

    delete p1;
    delete p2;
    delete p3;

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.
     
    Jerry Coffin, Jun 26, 2006
    #3
  4. asdf

    asdf Guest

    thanks man.

    Jerry Coffin wrote:
    > In article <>,
    > says...
    >
    > [ ... ]
    >
    > > 619 : delete p1, p2, p3;
    > > 620 : return ret;
    > > 621 : }
    > >
    > >
    > > 619: warning: right-hand operand of comma has no effect
    > > 619: warning: right-hand operand of comma has no effect

    >
    > The delete expression takes only one operand, so to delete all three
    > of these, you need:
    >
    > delete p1;
    > delete p2;
    > delete p3;
    >
    > --
    > Later,
    > Jerry.
    >
    > The universe is a figment of its own imagination.
     
    asdf, Jun 26, 2006
    #4
  5. asdf

    asdf Guest

    thanks.

    Jim Langston wrote:
    > "asdf" <> wrote in message
    > news:...
    > > Dear all,
    > >
    > > The following coding have two warnings in GCC, could you please figure
    > > it out for me? Thank you very much !
    > >
    > > 602 : EdgePair *p1, *p2, *p3;
    > > 603 :
    > > 604 : //
    > > 605 : if (ES_sanityCheck(e1,e2))
    > > 606 : p1 = new EdgePair(e1, e2);
    > > 607 : if (ES_sanityCheck(e2,e3))
    > > 608 : p2 = new EdgePair(e2, e3);
    > > 609 : if (ES_sanityCheck(e1,e3))
    > > 610 : p3 = new EdgePair(e1, e3);
    > > 611 :
    > > 612 : //
    > > 613 : //
    > > 614 : if (p1 && p2 && p3){
    > > 615 : bool ret = ES_sanityCheck(p1, p2) &&
    > > 616 : ES_sanityCheck(p1, p3) &&
    > > 617 : ES_sanityCheck(p2, p3);
    > > 618 :
    > > 619 : delete p1, p2, p3;

    >
    > delete p1;
    > delete p2;
    > delete p3;
    >
    > or
    >
    > delete p1, delete p2, delete p3;
    >
    > Otherwise p2 is just doing nothing whatsoever.
    >
    > > 620 : return ret;
    > > 621 : }
    > >
    > >
    > > 619: warning: right-hand operand of comma has no effect
    > > 619: warning: right-hand operand of comma has no effect
    > >
     
    asdf, Jun 26, 2006
    #5
    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. Charlie Zender
    Replies:
    12
    Views:
    1,086
    Peter Pichler
    Jan 3, 2004
  2. Charlie Zender

    Removing GCC compiler warnings from fabsf(), sqrtf()...

    Charlie Zender, Jan 2, 2004, in forum: C Programming
    Replies:
    8
    Views:
    636
    Ben Pfaff
    Jan 4, 2004
  3. Warnings with gcc

    , Nov 22, 2005, in forum: C Programming
    Replies:
    34
    Views:
    1,382
    Flash Gordon
    Nov 25, 2005
  4. asdf

    gcc warnings again

    asdf, Jun 26, 2006, in forum: C++
    Replies:
    12
    Views:
    587
    Jerry Coffin
    Jun 29, 2006
  5. Ted Sung
    Replies:
    1
    Views:
    316
    Sherm Pendley
    Aug 30, 2004
Loading...

Share This Page