diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-09-04 18:00:20 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-09-04 18:01:11 +0200 |
| commit | a767ae5d14063f3df1a3af994f26915f973de408 (patch) | |
| tree | acd84b4c078ac55cb587297737f57b92c9baf9c9 /src/inv.cpp | |
| parent | 49c0ef87bad8de7d3351b99eeae0e437adc60f0b (diff) | |
| download | PROJ-a767ae5d14063f3df1a3af994f26915f973de408.tar.gz PROJ-a767ae5d14063f3df1a3af994f26915f973de408.zip | |
Workaround 'Overlapping read/write of union is undefined behavior' cppcheck warning (but really fixing them would be more involved)
Diffstat (limited to 'src/inv.cpp')
| -rw-r--r-- | src/inv.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/inv.cpp b/src/inv.cpp index 8925f0e9..92b3c1d6 100644 --- a/src/inv.cpp +++ b/src/inv.cpp @@ -151,9 +151,15 @@ PJ_LP pj_inv(PJ_XY xy, PJ *P) { /* Do the transformation, using the lowest dimensional transformer available */ if (P->inv) - coo.lp = P->inv(coo.xy, P); + { + const auto lp = P->inv(coo.xy, P); + coo.lp = lp; + } else if (P->inv3d) - coo.lpz = P->inv3d (coo.xyz, P); + { + const auto lpz = P->inv3d (coo.xyz, P); + coo.lpz = lpz; + } else if (P->inv4d) coo = P->inv4d (coo, P); else { @@ -185,11 +191,17 @@ PJ_LPZ pj_inv3d (PJ_XYZ xyz, PJ *P) { /* Do the transformation, using the lowest dimensional transformer feasible */ if (P->inv3d) - coo.lpz = P->inv3d (coo.xyz, P); + { + const auto lpz = P->inv3d (coo.xyz, P); + coo.lpz = lpz; + } else if (P->inv4d) coo = P->inv4d (coo, P); else if (P->inv) - coo.lp = P->inv (coo.xy, P); + { + const auto lp = P->inv (coo.xy, P); + coo.lp = lp; + } else { proj_errno_set (P, PROJ_ERR_OTHER_NO_INVERSE_OP); return proj_coord_error ().lpz; @@ -219,9 +231,15 @@ PJ_COORD pj_inv4d (PJ_COORD coo, PJ *P) { if (P->inv4d) coo = P->inv4d (coo, P); else if (P->inv3d) - coo.lpz = P->inv3d (coo.xyz, P); + { + const auto lpz = P->inv3d (coo.xyz, P); + coo.lpz = lpz; + } else if (P->inv) - coo.lp = P->inv (coo.xy, P); + { + const auto lp = P->inv (coo.xy, P); + coo.lp = lp; + } else { proj_errno_set (P, PROJ_ERR_OTHER_NO_INVERSE_OP); return proj_coord_error (); |
