From: Matthew Fernandez Date: Sun, 13 Sep 2020 03:51:17 +0000 (-0700) Subject: remove undefined behavior in VPSC Constraint output X-Git-Tag: 2.46.0~20^2^2~73^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3178647a95d4095a03d679e0c2a8bdb8c6ed62f9;p=graphviz remove undefined behavior in VPSC Constraint output The address of a reference parameter can never be NULL. A reference parameter is, definitionally, non-NULL. So taking the address of a reference parameter and comparing it against NULL is always false. None of the call sites of this operator passed in NULL, so this change is a no-op from a user perspective, but it guards against future misuse. This addresses the following Coverity warning: Error: COMPILER_WARNING: [#def230] graphviz-2.40.1/lib/vpsc/constraint.cpp: scope_hint: In function 'std::ostream& operator<<(std::ostream&, const Constraint&)' graphviz-2.40.1/lib/vpsc/constraint.cpp:46:7: warning: the compiler can assume that the address of 'c' will never be NULL [-Waddress] # if(&c==NULL) { # ^ # 44| std::ostream& operator <<(std::ostream &os, const Constraint &c) # 45| { # 46|-> if(&c==NULL) { # 47| os<<"NULL"; # 48| } else { Related to #1464. --- diff --git a/lib/vpsc/constraint.cpp b/lib/vpsc/constraint.cpp index 10fa5b485..e3561a088 100644 --- a/lib/vpsc/constraint.cpp +++ b/lib/vpsc/constraint.cpp @@ -43,10 +43,6 @@ Constraint::~Constraint() { } std::ostream& operator <<(std::ostream &os, const Constraint &c) { - if(&c==NULL) { - os<<"NULL"; - } else { - os<<*c.left<<"+"<