public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nmm1 at cam dot ac.uk" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/57403] New: A vector of volatile int doesn't work, but one of volatile  void * does
Date: Fri, 24 May 2013 18:41:00 -0000	[thread overview]
Message-ID: <bug-57403-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 57403
           Summary: A vector of volatile int doesn't work, but one of
                    volatile  void * does
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nmm1 at cam dot ac.uk

In gcc 4.8.0, the following program fails horribly:

#include <vector>

int main () {
    std::vector<volatile int> memory(123);
}

Change the 'int' to void *' and it works.  It fails under OpenSUSE 11.4
and OpenSUSE 12.1, both on AMD 64-bit, and with gcc 4.6.2 as well.  The
messages are:

Test.cpp: In constructor 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp,
_Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp =
volatile int; _Alloc = std::allocator<volatile int>; std::vector<_Tp,
_Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type =
volatile int; std::vector<_Tp, _Alloc>::allocator_type =
std::allocator<volatile int>]':
Test.cpp:4:41: error: could not convert '0' from 'int' to 'const volatile
value_type& {aka const volatile int&}'
     std::vector<volatile int> memory(123);
                                         ^
Test.cpp: In function 'int main()':
Test.cpp:4:41: error: invalid initialization of reference of type 'const
volatile value_type& {aka const volatile int&}' from expression of type 'int'
In file included from /home/nmm/GCC/include/c++/4.8.0/vector:65:0,
                 from Test.cpp:1:
/home/nmm/GCC/include/c++/4.8.0/bits/stl_vector.h:296:7: error: in passing
argument 2 of 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp,
_Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp =
volatile int; _Alloc = std::allocator<volatile int>; std::vector<_Tp,
_Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type =
volatile int; std::vector<_Tp, _Alloc>::allocator_type =
std::allocator<volatile int>]'
       vector(size_type __n, const value_type& __value = value_type(),
       ^
In file included from
/home/nmm/GCC/include/c++/4.8.0/x86_64-unknown-linux-gnu/bits/c++allocator.h:33:0,
                 from /home/nmm/GCC/include/c++/4.8.0/bits/allocator.h:47,
                 from /home/nmm/GCC/include/c++/4.8.0/vector:62,
                 from Test.cpp:1:
/home/nmm/GCC/include/c++/4.8.0/ext/new_allocator.h: In instantiation of 'void
__gnu_cxx::new_allocator<_Tp>::deallocate(__gnu_cxx::new_allocator<_Tp>::pointer,
__gnu_cxx::new_allocator<_Tp>::size_type) [with _Tp = volatile int;
__gnu_cxx::new_allocator<_Tp>::pointer = volatile int*;
__gnu_cxx::new_allocator<_Tp>::size_type = long unsigned int]':
/home/nmm/GCC/include/c++/4.8.0/bits/stl_vector.h:175:4:   required from 'void
std::_Vector_base<_Tp, _Alloc>::_M_deallocate(std::_Vector_base<_Tp,
_Alloc>::pointer, std::size_t) [with _Tp = volatile int; _Alloc =
std::allocator<volatile int>; std::_Vector_base<_Tp, _Alloc>::pointer =
volatile int*; std::size_t = long unsigned int]'
/home/nmm/GCC/include/c++/4.8.0/bits/stl_vector.h:162:33:   required from
'std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = volatile int;
_Alloc = std::allocator<volatile int>]'
/home/nmm/GCC/include/c++/4.8.0/bits/stl_vector.h:298:23:   required from
'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const
value_type&, const allocator_type&) [with _Tp = volatile int; _Alloc =
std::allocator<volatile int>; std::vector<_Tp, _Alloc>::size_type = long
unsigned int; std::vector<_Tp, _Alloc>::value_type = volatile int;
std::vector<_Tp, _Alloc>::allocator_type = std::allocator<volatile int>]'
Test.cpp:4:41:   required from here
/home/nmm/GCC/include/c++/4.8.0/ext/new_allocator.h:110:30: error: invalid
conversion from 'volatile void*' to 'void*' [-fpermissive]
       { ::operator delete(__p); }
                              ^
In file included from /home/nmm/GCC/include/c++/4.8.0/ext/new_allocator.h:33:0,
                 from
/home/nmm/GCC/include/c++/4.8.0/x86_64-unknown-linux-gnu/bits/c++allocator.h:33,
                 from /home/nmm/GCC/include/c++/4.8.0/bits/allocator.h:47,
                 from /home/nmm/GCC/include/c++/4.8.0/vector:62,
                 from Test.cpp:1:
/home/nmm/GCC/include/c++/4.8.0/new:97:6: error:   initializing argument 1 of
'void operator delete(void*)' [-fpermissive]
 void operator delete(void*) _GLIBCXX_USE_NOEXCEPT
      ^


             reply	other threads:[~2013-05-24 18:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-24 18:41 nmm1 at cam dot ac.uk [this message]
2013-05-24 18:44 ` [Bug libstdc++/57403] " pinskia at gcc dot gnu.org
2013-05-24 19:02 ` nmm1 at cam dot ac.uk
2013-05-24 19:47 ` glisse at gcc dot gnu.org
2013-05-24 21:05 ` daniel.kruegler at googlemail dot com
2013-06-18 10:39 ` nmm1 at cam dot ac.uk
2014-10-13 14:40 ` 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-57403-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).