[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 327d53c 06/16: Conditionally suppress selecte
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 327d53c 06/16: Conditionally suppress selected x86_64-linux-gnu gcc-8 diagnostics |
Date: |
Thu, 15 Nov 2018 17:37:03 -0500 (EST) |
branch: master
commit 327d53c79588e57546362f4ceae52b335f371cf8
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Conditionally suppress selected x86_64-linux-gnu gcc-8 diagnostics
It is appropriate to suppress certain '-Wformat' diagnostics for edge
cases in a unit test of std::snprintf() where the compiler would warn
of exactly the exotic case deliberately being tested.
---
snprintf_test.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/snprintf_test.cpp b/snprintf_test.cpp
index 6f55f96..21eada9 100644
--- a/snprintf_test.cpp
+++ b/snprintf_test.cpp
@@ -43,12 +43,19 @@ int test_main(int, char*[])
BOOST_TEST_EQUAL(4, len);
// All tests in this group fail with the defective msvc rtl.
+#if defined __GNUC__
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wformat-truncation"
+#endif // defined __GNUC__
len = std::snprintf(buf, 3, "%4d", 1234);
BOOST_TEST_EQUAL(4, len);
// This test fails with borland C++ 5.5.1 .
BOOST_TEST_EQUAL(std::string(buf, 9), std::string("12\0zzzzzz\0", 9));
len = std::snprintf(buf, 4, "%4d", 1234);
+#if defined __GNUC__
+# pragma GCC diagnostic pop
+#endif // defined __GNUC__
BOOST_TEST_EQUAL(4, len);
// This test fails with the defective msvc rtl and also
// with borland C++ 5.5.1 .
@@ -59,11 +66,18 @@ int test_main(int, char*[])
BOOST_TEST_EQUAL(std::string(buf, 9), std::string("1234\0zzzz\0", 9));
long double z = 2.718281828459045L;
+#if defined __GNUC__
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wformat-truncation"
+#endif // defined __GNUC__
len = std::snprintf(buf, 5, "%.5Lf", z);
BOOST_TEST_EQUAL(7, len);
// This should truncate to 2.71, not round to 2.72 .
BOOST_TEST_EQUAL(std::string(buf, 9), std::string("2.71\0zzzz\0", 9));
len = std::snprintf(buf, 7, "%.5Lf", z);
+#if defined __GNUC__
+# pragma GCC diagnostic pop
+#endif // defined __GNUC__
BOOST_TEST_EQUAL(7, len);
BOOST_TEST_EQUAL(std::string(buf, 9), std::string("2.7182\0zz\0", 9));
len = std::snprintf(buf, 0, "%1.12Lf", z);
- [lmi-commits] [lmi] master updated (dd60056 -> 89e939b), Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 08e2d4c 03/16: Truncate sizeof(char*), Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 327d53c 06/16: Conditionally suppress selected x86_64-linux-gnu gcc-8 diagnostics,
Greg Chicares <=
- [lmi-commits] [lmi] master a1c1aa0 11/16: Avoid type 'long int', Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 158c2a1 08/16: Suppress x86_64-linux-gnu gcc-8 diagnostics for xmlwrapp, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master db0c484 02/16: Improve default gcc warning options, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master d425a61 10/16: Suppress some 86_64-linux-gnu gcc-8 '-Wconversion' diagnostics, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 9c34f2a 12/16: Don't mix std::size_t with fixed-width integer types, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 89e939b 16/16: Prefer lmi::ssize() to member size(), Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 0c4c5b6 01/16: Improve gcc dialect defaults, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 96dc6f5 07/16: Suppress certain diagnostics for another old boost library, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 5548922 14/16: Avoid gratuitous use of member size(), Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master fc8cf69 13/16: Prefer lmi::ssize() to member size(); rewrite a function out of line, Greg Chicares, 2018/11/15