Skip to content

Commit 51abb00

Browse files
Lutz Grossclaude
andcommitted
Fix MSVC narrowing warnings (and a latent paso reordering bug)
Four MSVC 2022 warnings on the win-64 conda-forge build, all in escript code: * paso/src/Options.h: Options::reordering was declared `bool`, but it stores a reordering *strategy code* (PASO_NO_REORDERING == 17, PASO_DEFAULT_REORDERING == 30, ...): it is set from mapEscriptOption(sb.getReordering()) and passed to MKL_solve(..., index_t reordering, ...) which switch()es on it. Storing those codes in a bool collapsed them all to 1, silently breaking MKL reordering selection on every platform (gcc/clang just didn't warn). Declare it `index_t`, which is what every consumer already expects. Fixes MSVC C4305. * ripley/src/RipleyDomain.cpp and speckley/src/SpeckleyDomain.cpp: pair<int,dim_t>(1, m_diracPoints.size()) narrowed the 64-bit size() to dim_t. Cast explicitly. Fixes MSVC C4267. * weipa/src/DataVar.cpp: std::copy from a double source into a float buffer. Replace with an explicit static_cast<float> loop (the narrowing is intended -- the VTK/SILO export buffer is single precision). Fixes C4244. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 7711604 commit 51abb00

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

paso/src/Options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ struct PASO_DLL_API Options
113113
double inner_tolerance;
114114
bool adapt_inner_tolerance;
115115
bool verbose;
116-
bool reordering;
116+
index_t reordering;
117117
int preconditioner;
118118
dim_t iter_max;
119119
dim_t inner_iter_max;

ripley/src/RipleyDomain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pair<int,dim_t> RipleyDomain::getDataShape(int fsType) const
169169
case ReducedFaceElements:
170170
return pair<int,dim_t>(1, getNumFaceElements());
171171
case Points:
172-
return pair<int,dim_t>(1, m_diracPoints.size());
172+
return pair<int,dim_t>(1, static_cast<dim_t>(m_diracPoints.size()));
173173
default:
174174
break;
175175
}

speckley/src/SpeckleyDomain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pair<int,dim_t> SpeckleyDomain::getDataShape(int fsType) const
117117
case ReducedElements:
118118
return pair<int,dim_t>(1, getNumElements());
119119
case Points:
120-
return pair<int,dim_t>(1, m_diracPoints.size());
120+
return pair<int,dim_t>(1, static_cast<dim_t>(m_diracPoints.size()));
121121
default:
122122
break;
123123
}

weipa/src/DataVar.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,16 @@ bool DataVar::initFromEscript(escript::Data& escriptData, const_DomainChunk_ptr
165165
const escript::DataTypes::real_t* values =
166166
escriptData.getDataRO();
167167
for (int pointNo=0; pointNo<numSamples*ptsPerSample; pointNo++) {
168-
copy(values, values+dimSize, destPtr);
168+
for (size_t i=0; i<dimSize; i++)
169+
destPtr[i] = static_cast<float>(values[i]);
169170
destPtr += dimSize;
170171
}
171172
} else {
172173
for (int sampleNo=0; sampleNo<numSamples; sampleNo++) {
173174
const escript::DataTypes::real_t* values =
174175
escriptData.getSampleDataRO(sampleNo);
175-
copy(values, values+dataSize, destPtr);
176+
for (size_t i=0; i<dataSize; i++)
177+
destPtr[i] = static_cast<float>(values[i]);
176178
destPtr += dataSize;
177179
}
178180
}

0 commit comments

Comments
 (0)