This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/61528] std::min std::max and RValue
- From: "glisse at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 22 Nov 2014 15:40:17 +0000
- Subject: [Bug c++/61528] std::min std::max and RValue
- Auto-submitted: auto-generated
- References: <bug-61528-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61528
--- Comment #8 from Marc Glisse <glisse at gcc dot gnu.org> ---
If I mark f as static or inline (so the optimizer changes f to take its
argument by value), I get with g++-5:
w2.c: In function 'int main()':
w2.c:11:7: warning: '<anonymous>' is used uninitialized in this function
[-Wuninitialized]
f(i);
^
w2.c:13:7: warning: '<anonymous>' is used uninitialized in this function
[-Wuninitialized]
f(a);
^
(not the best error message, but a good first step)
It is quite fragile though, if instead f is inlined (rename main to help
convince the optimizer), we end up with:
_49 = std::basic_ostream<char>::_M_insert<long unsigned int> (&cout, _9(D));
and don't warn about it (I didn't check, but I assume _9 is marked
TREE_NO_WARNING).