From e09e02527e403268516226e6a72385747fe02ad2 Mon Sep 17 00:00:00 2001 From: Susi Lehtola Date: Fri, 6 Feb 2026 10:15:43 +0200 Subject: [PATCH 1/2] Add sanity check for number of primitives --- include/gauxc/shell.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/gauxc/shell.hpp b/include/gauxc/shell.hpp index 7f27170c..d4786478 100644 --- a/include/gauxc/shell.hpp +++ b/include/gauxc/shell.hpp @@ -138,6 +138,9 @@ class alignas(256) Shell { alpha_( alpha ), coeff_( coeff ), O_( O ), nprim_( nprim.get() ), l_( l.get() ), pure_( pure.get() ) { + if(nprim_ > detail::shell_nprim_max) + throw std::out_of_range("Shell has too many primitives!\n"); + if( _normalize ) normalize(); compute_shell_cutoff(); From 4c28c8b06f0b928cd992de5d78611975a592bfb0 Mon Sep 17 00:00:00 2001 From: Susi Lehtola Date: Fri, 6 Feb 2026 17:55:22 +0200 Subject: [PATCH 2/2] Revision based on code review: include expected and erroneous values. --- include/gauxc/shell.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/gauxc/shell.hpp b/include/gauxc/shell.hpp index d4786478..01d35f42 100644 --- a/include/gauxc/shell.hpp +++ b/include/gauxc/shell.hpp @@ -138,8 +138,11 @@ class alignas(256) Shell { alpha_( alpha ), coeff_( coeff ), O_( O ), nprim_( nprim.get() ), l_( l.get() ), pure_( pure.get() ) { - if(nprim_ > detail::shell_nprim_max) - throw std::out_of_range("Shell has too many primitives!\n"); + if(nprim_ > detail::shell_nprim_max) { + std::ostringstream oss; + oss << "Shell has too many primitives! expected <= " << detail::shell_nprim_max << " actual value " << nprim_ << "!\n"; + throw std::out_of_range(oss.str()); + } if( _normalize ) normalize(); compute_shell_cutoff();