yann@402
|
1 |
Workaround for buglet in std::vector etc. when compiling
|
yann@402
|
2 |
with gcc-4.0.1 -Wall -O -fno-exceptions
|
yann@402
|
3 |
Fixes:
|
yann@402
|
4 |
|
yann@402
|
5 |
.../include/c++/4.0.0/bits/vector.tcc: In member function 'void std::vector<_Tp,
|
yann@402
|
6 |
_Alloc>::reserve(size_t) [with _Tp = int, _Alloc = std::allocator<int>]':
|
yann@402
|
7 |
.../include/c++/4.0.0/bits/vector.tcc:78: warning: control may reach end of
|
yann@402
|
8 |
non-void function 'typename _Alloc::pointer std::vector<_Tp,
|
yann@402
|
9 |
_Alloc>::_M_allocate_and_copy(size_t, _ForwardIterator, _ForwardIterator) [with
|
yann@402
|
10 |
_ForwardIterator = int*, _Tp = int, _Alloc = std::allocator<int>]' being inlined
|
yann@402
|
11 |
|
yann@402
|
12 |
See http://gcc.gnu.org/PR21951
|
yann@402
|
13 |
|
yann@402
|
14 |
To: gcc-patches at gcc dot gnu dot org
|
yann@402
|
15 |
Subject: [4.0.x] may reach end warning in system headers
|
yann@402
|
16 |
Message-Id: <20050701183024.E138714C16A9@geoffk5.apple.com>
|
yann@402
|
17 |
Date: Fri, 1 Jul 2005 11:30:24 -0700 (PDT)
|
yann@402
|
18 |
From: gkeating at apple dot com (Geoffrey Keating)
|
yann@402
|
19 |
|
yann@402
|
20 |
|
yann@402
|
21 |
One of our users was getting
|
yann@402
|
22 |
|
yann@402
|
23 |
/usr/include/gcc/darwin/4.0/c++/bits/stl_uninitialized.h:113: warning:
|
yann@402
|
24 |
control may reach end of non-void function '_ForwardIterator
|
yann@402
|
25 |
std::__uninitialized_copy_aux(_InputIterator, _InputIterator,
|
yann@402
|
26 |
_ForwardIterator, __false_type) [with _InputIterator =
|
yann@402
|
27 |
__gnu_cxx::__normal_iterator<TPoolAllocator::tAllocState*,
|
yann@402
|
28 |
std::vector<TPoolAllocator::tAllocState,
|
yann@402
|
29 |
std::allocator<TPoolAllocator::tAllocState> > >, _ForwardIterator =
|
yann@402
|
30 |
__gnu_cxx::__normal_iterator<TPoolAllocator::tAllocState*,
|
yann@402
|
31 |
std::vector<TPoolAllocator::tAllocState,
|
yann@402
|
32 |
std::allocator<TPoolAllocator::tAllocState> > >]' being inlined
|
yann@402
|
33 |
|
yann@402
|
34 |
which shouldn't be happening, he has no way to change a standard C++
|
yann@402
|
35 |
header. The warning is bogus anyway, but it's fixed in 4.1 through
|
yann@402
|
36 |
the CFG changes, which I don't really want to backport to the 4.0
|
yann@402
|
37 |
branch, so instead I'll add this patch. Other warnings generated from
|
yann@402
|
38 |
tree-inline.c check for DECL_SYSTEM_HEADER like this.
|
yann@402
|
39 |
|
yann@402
|
40 |
Bootstrapped & tested on powerpc-darwin8, I'll commit when the branch
|
yann@402
|
41 |
is unfrozen.
|
yann@402
|
42 |
|
yann@402
|
43 |
--
|
yann@402
|
44 |
- Geoffrey Keating <geoffk@apple.com>
|
yann@402
|
45 |
|
yann@402
|
46 |
===File ~/patches/gcc-40-4121982.patch======================
|
yann@402
|
47 |
Index: ChangeLog
|
yann@402
|
48 |
2005-06-28 Geoffrey Keating <geoffk@apple.com>
|
yann@402
|
49 |
|
yann@402
|
50 |
* tree-inline.c (expand_call_inline): Prevent 'may reach end'
|
yann@402
|
51 |
warning in system headers.
|
yann@402
|
52 |
|
yann@402
|
53 |
Index: tree-inline.c
|
yann@402
|
54 |
===================================================================
|
yann@402
|
55 |
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
|
yann@402
|
56 |
retrieving revision 1.170.8.4
|
yann@402
|
57 |
diff -u -p -u -p -r1.170.8.4 tree-inline.c
|
yann@402
|
58 |
--- gcc-4.0.1/gcc/tree-inline.c.old 6 Jun 2005 19:20:32 -0000 1.170.8.4
|
yann@402
|
59 |
+++ gcc-4.0.1/gcc/tree-inline.c 1 Jul 2005 18:27:26 -0000
|
yann@402
|
60 |
@@ -1693,7 +1693,8 @@ expand_call_inline (tree *tp, int *walk_
|
yann@402
|
61 |
&& !TREE_NO_WARNING (fn)
|
yann@402
|
62 |
&& !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (fn)))
|
yann@402
|
63 |
&& return_slot_addr == NULL_TREE
|
yann@402
|
64 |
- && block_may_fallthru (copy))
|
yann@402
|
65 |
+ && block_may_fallthru (copy)
|
yann@402
|
66 |
+ && !DECL_IN_SYSTEM_HEADER (fn))
|
yann@402
|
67 |
{
|
yann@402
|
68 |
warning ("control may reach end of non-void function %qD being inlined",
|
yann@402
|
69 |
fn);
|
yann@402
|
70 |
============================================================
|
yann@402
|
71 |
|