public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "olaf--mail.gcc at olafdietsche dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59192] New: error: use of deleted function ‘A::A(const A&)’
Date: Tue, 19 Nov 2013 16:04:00 -0000	[thread overview]
Message-ID: <bug-59192-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 59192
           Summary: error: use of deleted function ‘A::A(const A&)’
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olaf--mail.gcc at olafdietsche dot de

Created attachment 31250
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31250&action=edit
Generated with g++-4.7 -v -save-temps -c -Wall -std=c++11 a.cpp

The following snippet compiles fine with g++ 4.6 and fails with g++ 4.7 or g++
4.8 

#include <deque>
#include <vector>

struct A {
    A(const A&) = delete;
};

void f()
{
    std::vector<std::deque<A> > q;
    q.resize(4);
}

I attached the preprocessed file. If I missed a necessary part, please let
know.
System is Ubuntu 12.04

g++-4.7 -c -Wall -std=c++11 a.cpp
In file included from /usr/include/c++/4.7/deque:63:0,
                 from a.cpp:1:
/usr/include/c++/4.7/bits/stl_construct.h: In instantiation of ‘void
std::_Construct(_T1*, _Args&& ...) [with _T1 = A; _Args = {const A&}]’:
/usr/include/c++/4.7/bits/stl_uninitialized.h:77:3:   required from ‘static
_ForwardIterator
std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator,
_InputIterator, _ForwardIterator) [with _InputIterator =
std::_Deque_iterator<A, const A&, const A*>; _ForwardIterator =
std::_Deque_iterator<A, A&, A*>; bool _TrivialValueTypes = false]’
/usr/include/c++/4.7/bits/stl_uninitialized.h:119:41:   required from
‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator,
_ForwardIterator) [with _InputIterator = std::_Deque_iterator<A, const A&,
const A*>; _ForwardIterator = std::_Deque_iterator<A, A&, A*>]’
/usr/include/c++/4.7/bits/stl_uninitialized.h:260:63:   required from
‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator,
_ForwardIterator, std::allocator<_Tp>&) [with _InputIterator =
std::_Deque_iterator<A, const A&, const A*>; _ForwardIterator =
std::_Deque_iterator<A, A&, A*>; _Tp = A]’
/usr/include/c++/4.7/bits/stl_deque.h:841:9:   required from ‘std::deque<_Tp,
_Alloc>::deque(const std::deque<_Tp, _Alloc>&) [with _Tp = A; _Alloc =
std::allocator<A>; std::deque<_Tp, _Alloc> = std::deque<A>]’
/usr/include/c++/4.7/bits/stl_construct.h:77:7:   required from ‘void
std::_Construct(_T1*, _Args&& ...) [with _T1 = std::deque<A>; _Args =
{std::deque<A, std::allocator<A> >&}]’
/usr/include/c++/4.7/bits/stl_uninitialized.h:77:3:   required from ‘static
_ForwardIterator
std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator,
_InputIterator, _ForwardIterator) [with _InputIterator = std::deque<A>*;
_ForwardIterator = std::deque<A>*; bool _TrivialValueTypes = false]’
/usr/include/c++/4.7/bits/stl_uninitialized.h:119:41:   required from
‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator,
_ForwardIterator) [with _InputIterator = std::deque<A>*; _ForwardIterator =
std::deque<A>*]’
/usr/include/c++/4.7/bits/stl_uninitialized.h:260:63:   required from
‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator,
_ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = std::deque<A>*;
_ForwardIterator = std::deque<A>*; _Tp = std::deque<A>]’
/usr/include/c++/4.7/bits/stl_uninitialized.h:283:69:   required from
‘_ForwardIterator std::__uninitialized_move_if_noexcept_a(_InputIterator,
_InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator =
std::deque<A>*; _ForwardIterator = std::deque<A>*; _Allocator =
std::allocator<std::deque<A> >]’
/usr/include/c++/4.7/bits/vector.tcc:554:5:   required from ‘void
std::vector<_Tp, _Alloc>::_M_default_append(std::vector<_Tp,
_Alloc>::size_type) [with _Tp = std::deque<A>; _Alloc =
std::allocator<std::deque<A> >; std::vector<_Tp, _Alloc>::size_type = long
unsigned int]’
/usr/include/c++/4.7/bits/stl_vector.h:647:4:   required from ‘void
std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type) [with _Tp
= std::deque<A>; _Alloc = std::allocator<std::deque<A> >; std::vector<_Tp,
_Alloc>::size_type = long unsigned int]’
a.cpp:11:15:   required from here
/usr/include/c++/4.7/bits/stl_construct.h:77:7: error: use of deleted function
‘A::A(const A&)’
a.cpp:5:5: error: declared here


g++-4.7 -v
Using built-in specs.
COLLECT_GCC=g++-4.7
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.7.3-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin
--with-system-zlib --enable-objc-gc --with-cloog --enable-cloog-backend=ppl
--disable-cloog-version-check --disable-ppl-version-check --enable-multiarch
--disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1)
>From gcc-bugs-return-435092-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Nov 19 16:05:27 2013
Return-Path: <gcc-bugs-return-435092-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 31727 invoked by alias); 19 Nov 2013 16:05:27 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 31702 invoked by uid 48); 19 Nov 2013 16:05:24 -0000
From: "mtewoodbury at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/59193] New: Unused postfix operator temporaries
Date: Tue, 19 Nov 2013 16:05:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: minor
X-Bugzilla-Who: mtewoodbury at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-59193-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-11/txt/msg01869.txt.bz2
Content-length: 1025

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY193

            Bug ID: 59193
           Summary: Unused postfix operator temporaries
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mtewoodbury at gmail dot com

The use of postfix operators without using the value in their inherent
temporary store is a mild abuse of languages that provide those operators.
Compilers convert them to prefix operators as part of their optimization
process, but they waste space in automatic storage when the optimization is
insufficiently deep to detect them.

Reading the code in this project turns up hundreds of instances of this poor
practice.  Please convert these to the proper prefix operator form.

(More to the point, please accept patches that fix these problems without
abuse!  I have several sets that I will submit if there are no strong
objections.)


             reply	other threads:[~2013-11-19 16:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19 16:04 olaf--mail.gcc at olafdietsche dot de [this message]
2013-11-19 16:44 ` [Bug libstdc++/59192] " paolo.carlini at oracle dot com
2013-11-19 17:25 ` redi at gcc dot gnu.org
2014-01-05 20:50 ` rajveer_aujla at hotmail dot com
2014-01-05 21:04 ` redi at gcc dot gnu.org
2014-01-07 14:21 ` rajveer_aujla at hotmail dot com
2014-09-19 11:09 ` redi at gcc dot gnu.org
2015-09-03 10:28 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-59192-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).