Bug in HomCoord constructor
Hello, Looking at the code of HomCoord constructor inline HomCoord::HomCoord(const int coords[], const int num_coords) { for (int tmpj = 0; tmpj < num_coords; tmpj++) homCoord[tmpj] = coords[tmpj]; if (num_coords != 4) homCoord[3] = 1; } I see a bug in it because if called with num_coords < 3 then some of homCoord[] are uniinitialized. The fix is obvious, add a line: homCoord[0] = homCoord[1] = homCoord[2] = 0; Best regards, Roman -- Roman Putanowicz, PhD < [email protected] > Institute for Computational Civil Engng (L-5) Dept. of Civil Engng, Cracow Univ. of Technology www.l5.pk.edu.pl, tel. +48 12 628 2569, fax 2034
Roman, thanks for raising the issue. Yes, homCoord[1:4] should be initialized to zero in the constructor. I'll add this change. Vijay On Fri, May 12, 2017 at 8:18 PM, putanowr <[email protected]> wrote:
Hello,
Looking at the code of HomCoord constructor
inline HomCoord::HomCoord(const int coords[], const int num_coords) { for (int tmpj = 0; tmpj < num_coords; tmpj++) homCoord[tmpj] = coords[tmpj]; if (num_coords != 4) homCoord[3] = 1; }
I see a bug in it because if called with num_coords < 3 then some of homCoord[] are uniinitialized.
The fix is obvious, add a line: homCoord[0] = homCoord[1] = homCoord[2] = 0;
Best regards,
Roman
-- Roman Putanowicz, PhD < [email protected] > Institute for Computational Civil Engng (L-5) Dept. of Civil Engng, Cracow Univ. of Technology www.l5.pk.edu.pl, tel. +48 12 628 2569, fax 2034
participants (2)
-
putanowr -
Vijay S. Mahadevan