-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logically dead code in Collinear_3.h - static analysis #5207
Comments
I confirm that this looks suspicious. IIUC, the code is trying to find a reason to return false, by projecting along each of the axes in turn, before calling the base function. This seems to indicate that all the |
The code was added @sgiraudot by commit 4665299 of PR #2136. It seems the code was actually genereated (probably by FPG). The corresponding FT code is: cgal/Cartesian_kernel/include/CGAL/predicates/kernel_ftC3.h Lines 92 to 109 in 8698331
Probably FPG was not smart enough. |
Ah, yes, generated code would explain the strange variable names 😄 |
Would that be the right improvement: template < class FT >
CGAL_KERNEL_MEDIUM_INLINE
typename Equal_to<FT>::result_type
collinearC3(const FT &px, const FT &py, const FT &pz,
const FT &qx, const FT &qy, const FT &qz,
const FT &rx, const FT &ry, const FT &rz)
{
FT dpx = px-rx;
FT dqx = qx-rx;
FT dpy = py-ry;
FT dqy = qy-ry;
Uncertain<bool> not_zero = sign_of_determinant(dpx, dqx, dpy, dqy) != ZERO;
if (certainly(not_zero))
return false;
FT dpz = pz-rz;
FT dqz = qz-rz;
return CGAL_AND( ! not_zero,
sign_of_determinant(dpx, dqx, dpz, dqz) == ZERO ,
sign_of_determinant(dpy, dqy, dpz, dqz) == ZERO );
} |
I am also wondering if we should not use |
The above code adresses @mglisse remark "I think it could mimic CGAL_AND, store the first result as s, early out if certainly(s), and combine s with the final result.". |
|
As |
|
Issue Details
In the following code the value of of
int_tmp_result
is either set to1
, or-1
or the function is exited early via the returns. Thensign_of_determinant_return_value
(which is assigned from int_tmp_result) is checked to see if it is not equal to 0, which by the above code will always be true, so the function exits withreturn false;
cgal/Filtered_kernel/include/CGAL/internal/Static_filters/Collinear_3.h
Lines 74 to 104 in 16fc8d1
The remaining code in the function is therefore never executed. Either this is an indication of a different bug, or the dead code should be removed.
Environment
The text was updated successfully, but these errors were encountered: