Commit 615d1acb authored by Rob Latham's avatar Rob Latham Committed by Pavan Balaji
Browse files

implement MPIU_Assign_trunc without _Generic



The test suite has failures like this:

Assertion failed in file
/home/robl/work/mpich/src/mpid/ch3/src/ch3u_rma_ops.c at line 552
: ((dloop_vec[i].iov_len)/type_size) >= expr_inttype_min(count)

Even though dloop_vec[i].iov_len is 4, type_size is 4, and
expr_inttype_min(count) is -INT_MAX, this assertion is still failing.

while the _Generic-based test was giving strange assertion failures, the
cast-and-compare version still works and should be used.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@mcs.anl.gov>
parent e6962c16
......@@ -223,6 +223,10 @@ int MPIR_Assert_fail_fmt(const char *cond, const char *file_name, int line_num,
* promotion/truncation/conversion rules in mind. A discussion of these issues
* can be found in Chapter 5 of "Secure Coding in C and C++" by Robert Seacord.
*/
/* this "check for overflow" macro seems buggy in a crazy way that I can't
* figure out. Instead of using the clever 'expr_inttype_max' macro, fall back
* to simple "cast and check for obvious overflow" */
#if 0
#if defined(expr_inttype_max) && defined(expr_inttype_min)
# define MPIU_Assign_trunc(dst_,src_,dst_type_) \
do { \
......@@ -231,14 +235,14 @@ int MPIR_Assert_fail_fmt(const char *cond, const char *file_name, int line_num,
MPIU_Assert((src_) >= expr_inttype_min(dst_)); \
dst_ = (dst_type_)(src_); \
} while (0)
#else
# define MPIU_Assign_trunc(dst_,src_,dst_type_) \
#endif
#endif
#define MPIU_Assign_trunc(dst_,src_,dst_type_) \
do { \
dst_ = (dst_type_)(src_); \
/* will catch some of the cases if the expr_inttype macros aren't available */ \
MPIU_Assert((dst_) == (src_)); \
} while (0)
#endif
/*
* Ensure an MPI_Aint value fits into a signed int.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment