public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21951] New: [gcc-4.0 regression, rejects-valid] std::vector.reserve() unusable with -Werror -Wall -O -fno-exceptions
@ 2005-06-07 17:58 dank at kegel dot com
  2005-06-07 18:00 ` [Bug c++/21951] " pinskia at gcc dot gnu dot org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: dank at kegel dot com @ 2005-06-07 17:58 UTC (permalink / raw)
  To: gcc-bugs

Compiling the following code:

#include <vector>
std::vector<int> *factory()
{
        std::vector<int> *p = new std::vector<int>;
        p->reserve(10);
        return p;
}

with -Wall -O -fno-exceptions yields the following error in gcc-4.0.0
and gcc-4.0-20050602:

.../include/c++/4.0.0/bits/vector.tcc: In member function 'void std::vector<_Tp,
_Alloc>::reserve(size_t) [with _Tp = int, _Alloc = std::allocator<int>]':
.../include/c++/4.0.0/bits/vector.tcc:78: warning: control may reach end of
non-void function 'typename _Alloc::pointer std::vector<_Tp,
_Alloc>::_M_allocate_and_copy(size_t, _ForwardIterator, _ForwardIterator) [with
_ForwardIterator = int*, _Tp = int, _Alloc = std::allocator<int>]' being inlined

The warning comes from a catch/rethrow block deep in the bowels of stl
which (because of -fno-exceptions) evaluates to if(false).

This is a false positive warning, which would be fine except
for shops whose policy is to always compile with -Werror -Wall;
there, the warning is fatal.  And because this problem is not
confined to just one user source file, it's hard to work around.

This problem does not occur in gcc-3.4.3 nor in recent gcc-4.1 snapshots.

cf. discussion here: http://gcc.gnu.org/ml/libstdc++/2005-06/msg00073.html

-- 
           Summary: [gcc-4.0 regression, rejects-valid]
                    std::vector.reserve() unusable with -Werror -Wall -O -
                    fno-exceptions
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dank at kegel dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21951


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2005-07-16 21:01 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-07 17:58 [Bug c++/21951] New: [gcc-4.0 regression, rejects-valid] std::vector.reserve() unusable with -Werror -Wall -O -fno-exceptions dank at kegel dot com
2005-06-07 18:00 ` [Bug c++/21951] " pinskia at gcc dot gnu dot org
2005-06-07 18:12 ` pcarlini at suse dot de
2005-06-07 18:17 ` pinskia at gcc dot gnu dot org
2005-06-07 19:46 ` veksler at il dot ibm dot com
2005-06-07 23:28 ` [Bug libstdc++/21951] " bangerth at dealii dot org
2005-06-08 13:20 ` [Bug libstdc++/21951] [4.0 only] " pinskia at gcc dot gnu dot org
2005-06-08 13:57 ` dank at kegel dot com
2005-06-08 14:11 ` veksler at il dot ibm dot com
2005-06-08 14:43 ` veksler at il dot ibm dot com
2005-06-08 19:16 ` bkoz at gcc dot gnu dot org
2005-06-11 11:25 ` dank at kegel dot com
2005-06-11 19:29 ` dank at kegel dot com
2005-06-12 15:02 ` pinskia at gcc dot gnu dot org
2005-07-01 19:10 ` geoffk at gcc dot gnu dot org
2005-07-01 19:42 ` dank at kegel dot com
2005-07-16 21:12 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).