gcc warnings

A

asdf

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
 
J

Jim Langston

asdf said:
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.
 
J

Jerry Coffin

[ ... ]
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;
 
A

asdf

thanks man.

Jerry said:
[ ... ]
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top