aboutsummaryrefslogtreecommitdiff
path: root/src/fwd.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-09-04 18:00:20 +0200
committerEven Rouault <even.rouault@spatialys.com>2021-09-04 18:01:11 +0200
commita767ae5d14063f3df1a3af994f26915f973de408 (patch)
treeacd84b4c078ac55cb587297737f57b92c9baf9c9 /src/fwd.cpp
parent49c0ef87bad8de7d3351b99eeae0e437adc60f0b (diff)
downloadPROJ-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/fwd.cpp')
-rw-r--r--src/fwd.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/fwd.cpp b/src/fwd.cpp
index 8583a6e7..c267dfca 100644
--- a/src/fwd.cpp
+++ b/src/fwd.cpp
@@ -193,9 +193,15 @@ PJ_XY pj_fwd(PJ_LP lp, PJ *P) {
/* Do the transformation, using the lowest dimensional transformer available */
if (P->fwd)
- coo.xy = P->fwd(coo.lp, P);
+ {
+ const auto xy = P->fwd(coo.lp, P);
+ coo.xy = xy;
+ }
else if (P->fwd3d)
- coo.xyz = P->fwd3d (coo.lpz, P);
+ {
+ const auto xyz = P->fwd3d (coo.lpz, P);
+ coo.xyz = xyz;
+ }
else if (P->fwd4d)
coo = P->fwd4d (coo, P);
else {
@@ -227,11 +233,17 @@ PJ_XYZ pj_fwd3d(PJ_LPZ lpz, PJ *P) {
/* Do the transformation, using the lowest dimensional transformer feasible */
if (P->fwd3d)
- coo.xyz = P->fwd3d(coo.lpz, P);
+ {
+ const auto xyz = P->fwd3d(coo.lpz, P);
+ coo.xyz = xyz;
+ }
else if (P->fwd4d)
coo = P->fwd4d (coo, P);
else if (P->fwd)
- coo.xy = P->fwd (coo.lp, P);
+ {
+ const auto xy = P->fwd (coo.lp, P);
+ coo.xy = xy;
+ }
else {
proj_errno_set (P, PROJ_ERR_OTHER_NO_INVERSE_OP);
return proj_coord_error ().xyz;
@@ -261,9 +273,15 @@ PJ_COORD pj_fwd4d (PJ_COORD coo, PJ *P) {
if (P->fwd4d)
coo = P->fwd4d (coo, P);
else if (P->fwd3d)
- coo.xyz = P->fwd3d (coo.lpz, P);
+ {
+ const auto xyz = P->fwd3d (coo.lpz, P);
+ coo.xyz = xyz;
+ }
else if (P->fwd)
- coo.xy = P->fwd (coo.lp, P);
+ {
+ const auto xy = P->fwd (coo.lp, P);
+ coo.xy = xy;
+ }
else {
proj_errno_set (P, PROJ_ERR_OTHER_NO_INVERSE_OP);
return proj_coord_error ();