This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: __atomic_futex_unsigned::_M_load_when_not_equal has a 'return' statement with no value, in function returning unsigned int
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Patrick Palka <patrick at parcs dot ath dot cx>
- Cc: libstdc++ at gcc dot gnu dot org, triegel at redhat dot com
- Date: Thu, 23 Jul 2015 09:21:03 +0100
- Subject: Re: __atomic_futex_unsigned::_M_load_when_not_equal has a 'return' statement with no value, in function returning unsigned int
- Authentication-results: sourceware.org; auth=none
- References: <CA+C-WL-r5b-yq8xPSL8KxgRFy+2Od0wKMD7CNj7T1BGUWVODzw at mail dot gmail dot com>
On 22/07/15 22:30 -0400, Patrick Palka wrote:
Specifically, line 149 of atomix_futex.h has a bare "return;"
statement, but the function is marked as returning non-void. This was
caught while working on PR c++/18969. Vanilla G++ does not catch this
error because return statements inside templates are currently only
analyzed during instantiation time.
Ouch. Luckily that function is never called, so it's not doing any
harm.
Torvald, assuming we want to keep that unused function, is this the
right fix?
diff --git a/libstdc++-v3/include/bits/atomic_futex.h b/libstdc++-v3/include/bits/atomic_futex.h
index ca3260d..5b126c8 100644
--- a/libstdc++-v3/include/bits/atomic_futex.h
+++ b/libstdc++-v3/include/bits/atomic_futex.h
@@ -146,7 +146,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_load_when_not_equal(unsigned __val, memory_order __mo)
{
unsigned __i = _M_load(__mo);
- if ((__i & ~_Waiter_bit) != __val) return;
+ if ((__i & ~_Waiter_bit) != __val)
+ return (__i & ~_Waiter_bit);
// TODO Spin-wait first.
return _M_load_and_test(__i, __val, false, __mo);
}