From e2edf298abe3e811e8d248bcdf3705a2f5a506f5 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Sun, 7 Feb 2021 17:44:59 +0000 Subject: [PATCH] lte: (fixes #346) ASN1 header gcc7 fix --- src/lte/model/lte-asn1-header.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lte/model/lte-asn1-header.cc b/src/lte/model/lte-asn1-header.cc index 095512525..767d30970 100644 --- a/src/lte/model/lte-asn1-header.cc +++ b/src/lte/model/lte-asn1-header.cc @@ -321,7 +321,14 @@ void Asn1Header::SerializeChoice (int numOptions, int selectedOption, bool isExt void Asn1Header::SerializeInteger (int n, int nmin, int nmax) const { - NS_ASSERT_MSG (nmin <= n && n <= nmax, + // The following is equivalent to: + // NS_ASSERT_MSG (nmin <= n && n <= nmax, + // "Integer " << n << " is outside range [" << nmin << ", " << nmax << "]"); + // This is a workaround to gcc-7 aggressive optimization, see #346, and can be dropped + // once gcc-7 will not be anymore supported. + long int nComp = nmin; + nComp -= n; + NS_ASSERT_MSG (nComp <= 0 && n <= nmax, "Integer " << n << " is outside range [" << nmin << ", " << nmax << "]"); // Clause 11.5.3 ITU-T X.691