Skip to content

Commit 9f556ac

Browse files
authored
Merge pull request #3568 from roystgnr/sanitize_integer
Get a clean `-fsanitize=integer` run of `make check`
2 parents 6467995 + 4b99bb8 commit 9f556ac

25 files changed

Lines changed: 80 additions & 57 deletions

contrib/fparser/util/bytecoderules_parser.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ namespace
131131
size_t indent)
132132
{
133133
std::string codehash, prevlabel;
134-
for(size_t a=chain.size(); a-- > 0; )
134+
for(ptrdiff_t a=chain.size(); a-- > 0; )
135135
{
136136
codehash += chain[a];
137137
std::string label = GenLabel(codehash);
@@ -509,7 +509,7 @@ namespace
509509
outstream << "\n" << Indent(indent+1);
510510

511511
outstream << '"';
512-
for(size_t a=so_far.size(); a-- > 0; )
512+
for(ptrdiff_t a=so_far.size(); a-- > 0; )
513513
{
514514
if(a+1 != so_far.size()) outstream << " ";
515515
outstream << so_far[a].name;
@@ -1269,7 +1269,7 @@ namespace
12691269
}
12701270

12711271
Node* head = &global_head;
1272-
for(size_t b=sequence.size(); b-->0; )
1272+
for(ptrdiff_t b=sequence.size(); b-->0; )
12731273
{
12741274
const Match& m = sequence[b];
12751275
bool dup = false;

fsanitize_ignorelist.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This is a set of exceptions to use in
2+
# '-fsanitize-ignorelist=yourdir/fsanitize_ignorelist.txt'
3+
#
4+
# So far it's been tested and found to be complete for
5+
# -fsanitize=integer on clang++ 14 with g++ 12.1.0 headers
6+
fun:*basic_string_view*rfind*
7+
fun:*basic_string*compare*
8+
src:*hashing.h
9+
src:*hashword.h
10+
src:*libHilbert*SetBits*
11+
src:*fpoptimizer*
12+
src:*fp_opcode_add*
13+
src:*bytecodesynth*
14+
src:*fparser.cc
15+
src:*Eigen/*

include/base/getpot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2777,7 +2777,7 @@ GetPot::_DBE_expand_string(const std::string& str)
27772777
unsigned first = 0;
27782778
for (unsigned i = 0; i<str.size(); i++)
27792779
{
2780-
if (i < str.size() - 2 && str.substr(i, 2) == "${")
2780+
if (i + 2 < str.size() && str.substr(i, 2) == "${")
27812781
{
27822782
if (open_brackets == 0)
27832783
first = i+2;

include/mesh/namebased_io.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ NameBasedIO::is_parallel_file_format (std::string_view name)
125125
{
126126
return ((name.rfind(".xda") < name.size()) ||
127127
(name.rfind(".xdr") < name.size()) ||
128-
(name.rfind(".nem") + 4 == name.size()) ||
129-
(name.rfind(".n") + 2 == name.size()) ||
128+
(name.rfind(".nem") == name.size() - 4) ||
129+
(name.rfind(".n") == name.size() - 2) ||
130130
(name.rfind(".cp") < name.size())
131131
);
132132
}

include/reduced_basis/rb_construction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ class RBConstruction : public RBConstructionBase<LinearImplicitSystem>
427427
*/
428428
void set_rb_construction_parameters(unsigned int n_training_samples_in,
429429
bool deterministic_training_in,
430-
unsigned int training_parameters_random_seed_in,
430+
int training_parameters_random_seed_in,
431431
bool quiet_mode_in,
432432
unsigned int Nmax_in,
433433
Real rel_training_tolerance_in,

include/reduced_basis/rb_construction_base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class RBConstructionBase : public Base, public RBParametrized
156156
/**
157157
* Set the seed that is used to randomly generate training parameters.
158158
*/
159-
void set_training_random_seed(unsigned int seed);
159+
void set_training_random_seed(int seed);
160160

161161
/**
162162
* In some cases we only want to allow discrete parameter values, instead

include/reduced_basis/rb_eim_construction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class RBEIMConstruction : public RBConstructionBase<System>
128128
*/
129129
void set_rb_construction_parameters(unsigned int n_training_samples_in,
130130
bool deterministic_training_in,
131-
unsigned int training_parameters_random_seed_in,
131+
int training_parameters_random_seed_in,
132132
bool quiet_mode_in,
133133
unsigned int Nmax_in,
134134
Real rel_training_tolerance_in,

src/base/dof_map.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,7 +2447,7 @@ void DofMap::_dof_indices (const Elem & elem,
24472447
di.resize(di.size() + nc, DofObject::invalid_id);
24482448
}
24492449
else
2450-
for (int i=n_comp-1; i>=dof_offset; i--)
2450+
for (int i=int(n_comp)-1; i>=dof_offset; i--)
24512451
{
24522452
const dof_id_type d =
24532453
node.dof_number(sys_num, vg, vig, i, n_comp);
@@ -2685,7 +2685,7 @@ void DofMap::old_dof_indices (const Elem * const elem,
26852685
}
26862686

26872687
// Compute the net amount of "extra" order, including Elem::p_level()
2688-
int extra_order = elem->p_level() + p_adjustment;
2688+
int extra_order = int(elem->p_level()) + p_adjustment;
26892689

26902690
FEType fe_type = var.type();
26912691

src/base/dof_map_constraints.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ dof_id_type DofMap::n_local_constrained_dofs() const
17171717
const DofConstraints::const_iterator lower =
17181718
_dof_constraints.lower_bound(this->first_dof()),
17191719
upper =
1720-
_dof_constraints.upper_bound(this->end_dof()-1);
1720+
_dof_constraints.lower_bound(this->end_dof());
17211721

17221722
return cast_int<dof_id_type>(std::distance(lower, upper));
17231723
}
@@ -2086,7 +2086,7 @@ void DofMap::process_mesh_constraint_rows(const MeshBase & mesh)
20862086

20872087
if (was_previously_constrained.count(constrained_id))
20882088
{
2089-
for (auto q : IntRange<unsigned int>(0, n_adjoint_rhs+1))
2089+
for (auto q : IntRange<int>(0, n_adjoint_rhs+1))
20902090
{
20912091
DenseMatrix<Number> K(1,1);
20922092
DenseVector<Number> F(1);

0 commit comments

Comments
 (0)