This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Buggy test 20_util/exchange/1.cc
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Diego Novillo <dnovillo at google dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 15 Oct 2013 18:27:47 +0100
- Subject: Re: Buggy test 20_util/exchange/1.cc
- Authentication-results: sourceware.org; auth=none
- References: <CAD_=9DTa1_awPYmgjfR7NvYdRzC-38JaPmuBTdxirNrTRoan1w at mail dot gmail dot com>
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