Skip to content

fixes for c++20#147

Merged
plexoos merged 6 commits into
mainfrom
fix-c++20
Sep 3, 2025
Merged

fixes for c++20#147
plexoos merged 6 commits into
mainfrom
fix-c++20

Conversation

@plexoos

@plexoos plexoos commented Sep 3, 2025

Copy link
Copy Markdown
Member

No description provided.

@plexoos plexoos requested a review from Copilot September 3, 2025 12:18

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v18.1.3

Click here for the full clang-format patch
diff --git a/sysrap/scuda.h b/sysrap/scuda.h
index 707ed11..d791a65 100644
--- a/sysrap/scuda.h
+++ b/sysrap/scuda.h
@@ -104 +103,0 @@ SUTIL_INLINE SUTIL_HOSTDEVICE unsigned long long min(unsigned long long a, unsig
-
@@ -108 +107 @@ SUTIL_INLINE SUTIL_HOSTDEVICE unsigned long long min(unsigned long long a, unsig
-using std::lerp;   // make std::lerp visible to unqualified calls
+using std::lerp;                   // make std::lerp visible to unqualified calls
@@ -119,2 +117,0 @@ SUTIL_INLINE SUTIL_HOSTDEVICE float lerp(const float a, const float b, const flo
-
-
diff --git a/u4/U4SolidMaker.cc b/u4/U4SolidMaker.cc
index c5881de..ab589a6 100644
--- a/u4/U4SolidMaker.cc
+++ b/u4/U4SolidMaker.cc
@@ -2154 +2154 @@ const G4VSolid* U4SolidMaker::BltLocalFastenerAcrylicConstruction(const char* na
-    std::vector<G4ThreeVector> tlate(num_column, G4ThreeVector(0,0,0));
+    std::vector<G4ThreeVector> tlate(num_column, G4ThreeVector(0, 0, 0));
@@ -2156 +2156,2 @@ const G4VSolid* U4SolidMaker::BltLocalFastenerAcrylicConstruction(const char* na
-    for(long i=0;i<num_column;i++) tlate[i] = G4ThreeVector(164.*cos(i*pi/4)*mm, 164.*sin(i*pi/4)*mm,-65.0*mm);
+    for (long i = 0; i < num_column; i++)
+        tlate[i] = G4ThreeVector(164. * cos(i * pi / 4) * mm, 164. * sin(i * pi / 4) * mm, -65.0 * mm);

Have any feedback or feature suggestions? Share it here.

Comment thread sysrap/scuda.h Outdated
Comment thread sysrap/scuda.h Outdated
Comment thread sysrap/scuda.h Outdated
Comment thread u4/U4SolidMaker.cc Outdated
Comment thread u4/U4SolidMaker.cc Outdated

This comment was marked as outdated.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions Bot dismissed their stale review September 3, 2025 14:20

outdated suggestion

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v18.1.3

Click here for the full clang-format patch
diff --git a/sysrap/scuda.h b/sysrap/scuda.h
index d547473..d791a65 100644
--- a/sysrap/scuda.h
+++ b/sysrap/scuda.h
@@ -104 +103,0 @@ SUTIL_INLINE SUTIL_HOSTDEVICE unsigned long long min(unsigned long long a, unsig
-
@@ -119,2 +117,0 @@ SUTIL_INLINE SUTIL_HOSTDEVICE float lerp(const float a, const float b, const flo
-
-

Have any feedback or feature suggestions? Share it here.

Comment thread sysrap/scuda.h Outdated
Comment thread sysrap/scuda.h Outdated
@github-actions github-actions Bot dismissed their stale review September 3, 2025 14:29

outdated suggestion

@plexoos plexoos requested a review from Copilot September 3, 2025 14:36
@plexoos plexoos merged commit 0ae57ef into main Sep 3, 2025
3 checks passed
@plexoos plexoos deleted the fix-c++20 branch September 3, 2025 14:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses compatibility issues with C++20 by resolving conflicts and updating code patterns that are incompatible with the newer standard.

  • Replaces variable-length arrays with std::vector for C++20 compatibility
  • Handles std::lerp conflicts by conditionally using std::lerp when available
  • Updates CMake configuration to properly link OpenSSL libraries

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
u4/U4SolidMaker.cc Converts variable-length array to std::vector and adds proper type casting
sysrap/scuda.h Adds conditional compilation to handle std::lerp availability in C++20
qudarap/CMakeLists.txt Updates OpenSSL linking to use proper CMake targets

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread u4/U4SolidMaker.cc
Comment on lines +2156 to 2160
for (long i = 0; i < num_column; i++)
tlate[i] = G4ThreeVector(164. * cos(i * pi / 4) * mm, 164. * sin(i * pi / 4) * mm, -65.0 * mm);

G4VSolid* muni = screw ;
for(long i=1 ; i < num_column ; i++) muni = new G4UnionSolid( name, muni, screw, 0, tlate[i] ) ;

Copilot AI Sep 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loop variable type mismatch: i is declared as long but num_column is size_t. This can cause signed/unsigned comparison warnings and potential issues on platforms where long and size_t have different sizes. Change the loop variable to size_t i = 0.

Suggested change
for (long i = 0; i < num_column; i++)
tlate[i] = G4ThreeVector(164. * cos(i * pi / 4) * mm, 164. * sin(i * pi / 4) * mm, -65.0 * mm);
G4VSolid* muni = screw ;
for(long i=1 ; i < num_column ; i++) muni = new G4UnionSolid( name, muni, screw, 0, tlate[i] ) ;
for (size_t i = 0; i < num_column; i++)
tlate[i] = G4ThreeVector(164. * cos(i * pi / 4) * mm, 164. * sin(i * pi / 4) * mm, -65.0 * mm);
G4VSolid* muni = screw ;
for(size_t i=1 ; i < num_column ; i++) muni = new G4UnionSolid( name, muni, screw, 0, tlate[i] ) ;

Copilot uses AI. Check for mistakes.
Comment thread u4/U4SolidMaker.cc
Comment on lines +2156 to 2160
for (long i = 0; i < num_column; i++)
tlate[i] = G4ThreeVector(164. * cos(i * pi / 4) * mm, 164. * sin(i * pi / 4) * mm, -65.0 * mm);

G4VSolid* muni = screw ;
for(long i=1 ; i < num_column ; i++) muni = new G4UnionSolid( name, muni, screw, 0, tlate[i] ) ;

Copilot AI Sep 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loop variable type mismatch: i is declared as long but num_column is size_t. This can cause signed/unsigned comparison warnings and potential issues. Change the loop variable to size_t i = 1.

Suggested change
for (long i = 0; i < num_column; i++)
tlate[i] = G4ThreeVector(164. * cos(i * pi / 4) * mm, 164. * sin(i * pi / 4) * mm, -65.0 * mm);
G4VSolid* muni = screw ;
for(long i=1 ; i < num_column ; i++) muni = new G4UnionSolid( name, muni, screw, 0, tlate[i] ) ;
for (size_t i = 0; i < num_column; i++)
tlate[i] = G4ThreeVector(164. * cos(i * pi / 4) * mm, 164. * sin(i * pi / 4) * mm, -65.0 * mm);
G4VSolid* muni = screw ;
for(size_t i=1 ; i < num_column ; i++) muni = new G4UnionSolid( name, muni, screw, 0, tlate[i] ) ;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants