Buggy test 20_util/exchange/1.cc

Diego Novillo dnovillo@google.com
Tue Oct 15 18:12:00 GMT 2013


On Tue, Oct 15, 2013 at 10:27 AM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 15 October 2013 17:57, Diego Novillo wrote:
>> This test fails to link unless compiled with -O2. The compiler is
>> eliding the whole body of test03(), so everything links and runs
>> properly.
>>
>> // Deduce type of overloaded function
>> void
>> test03()
>> {
>>   bool test __attribute__((unused)) = true;
>>   int (*fp)(int);  int f(int);
>>   double f(double);
>>   std::exchange(fp, &f);
>>   VERIFY( fp != nullptr );
>> }
>>
>> However, at -O0, the address of f() is really needed, so we fail to link.
>>
>> This test really needs an empty f() function.  Would such a patch be OK?
>
> Yes sure, thanks.
>
> FWIW, the test came from an example in the proposal:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3668.html

Thanks.  Is this OK to commit?


Diego.

* testsuite/20_util/exchange/1.cc: Add missing function
bodies.
---
 libstdc++-v3/ChangeLog                       | 5 +++++
 libstdc++-v3/testsuite/20_util/exchange/1.cc | 6 ++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index b1d6e04..ca453a9 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-15  Diego Novillo  <dnovillo@google.com>
+
+ * testsuite/20_util/exchange/1.cc: Add missing function
+ bodies.
+
 2013-10-15  Tim Shen  <timshen91@gmail.com>

  PR libstdc++/58737
diff --git a/libstdc++-v3/testsuite/20_util/exchange/1.cc
b/libstdc++-v3/testsuite/20_util/exchange/1.cc
index d16d9e9..2880c53 100644
--- a/libstdc++-v3/testsuite/20_util/exchange/1.cc
+++ b/libstdc++-v3/testsuite/20_util/exchange/1.cc
@@ -55,6 +55,10 @@ test02()
   VERIFY( old.value == 1 );
 }

+int f(int __attribute__((unused)) x) { return 0; }
+
+double f(double __attribute__((unused)) x) { return 0; }
+
 // Deduce type of overloaded function
 void
 test03()
@@ -62,8 +66,6 @@ test03()
   bool test __attribute__((unused)) = true;

   int (*fp)(int);
-  int f(int);
-  double f(double);
   std::exchange(fp, &f);
   VERIFY( fp != nullptr );
 }
-- 
1.8.4



More information about the Libstdc++ mailing list