public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/57403] New: A vector of volatile int doesn't work, but one of volatile void * does
@ 2013-05-24 18:41 nmm1 at cam dot ac.uk
2013-05-24 18:44 ` [Bug libstdc++/57403] " pinskia at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: nmm1 at cam dot ac.uk @ 2013-05-24 18:41 UTC (permalink / raw)
To: gcc-bugs
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
^
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/57403] A vector of volatile int doesn't work, but one of volatile void * does
2013-05-24 18:41 [Bug libstdc++/57403] New: A vector of volatile int doesn't work, but one of volatile void * does nmm1 at cam dot ac.uk
@ 2013-05-24 18:44 ` pinskia at gcc dot gnu.org
2013-05-24 19:02 ` nmm1 at cam dot ac.uk
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-05-24 18:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57403
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Well volatile void * is a pointer to volatile void and the pointer itself does
not have the volatile on it.
I think the only real issue here is the error message. IIRC allocators do not
(and cannot) support volatile qualified types.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/57403] A vector of volatile int doesn't work, but one of volatile void * does
2013-05-24 18:41 [Bug libstdc++/57403] New: A vector of volatile int doesn't work, but one of volatile void * does nmm1 at cam dot ac.uk
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
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: nmm1 at cam dot ac.uk @ 2013-05-24 19:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57403
--- Comment #2 from Nick Maclaren <nmm1 at cam dot ac.uk> ---
On May 24 2013, pinskia at gcc dot gnu.org wrote:
>http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57403
>
> --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Well
> volatile void * is a pointer to volatile void and the pointer itself does
> not have the volatile on it.
Aargh! Even after all this time, I still fall into that one :-( Yes,
you are quite right, and I was making a stupid error.
> I think the only real issue here is the error message. IIRC allocators do
> not (and cannot) support volatile qualified types.
That may well be true, but I can't find any such restriction in the C++
standard. It would be a great help if the library specification weren't
so ambiguous - in this case, it hinges around the meaning of the word
'type', and the unqualified word is used with at least three meanings
in the standard.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/57403] A vector of volatile int doesn't work, but one of volatile void * does
2013-05-24 18:41 [Bug libstdc++/57403] New: A vector of volatile int doesn't work, but one of volatile void * does nmm1 at cam dot ac.uk
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
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-05-24 19:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57403
--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Nick Maclaren from comment #2)
> That may well be true, but I can't find any such restriction in the C++
> standard. It would be a great help if the library specification weren't
> so ambiguous - in this case, it hinges around the meaning of the word
> 'type', and the unqualified word is used with at least three meanings
> in the standard.
C++03 gives the prototype of the constructor:
explicit vector(size_type n, const T& value = T(), const Allocator& =
Allocator());
which shows that it can't work:
typedef volatile int T;
void f () { T const& a = T(); }
For C++11, the prototype changed, it gets harder to follow...
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/57403] A vector of volatile int doesn't work, but one of volatile void * does
2013-05-24 18:41 [Bug libstdc++/57403] New: A vector of volatile int doesn't work, but one of volatile void * does nmm1 at cam dot ac.uk
` (2 preceding siblings ...)
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
5 siblings, 0 replies; 7+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-05-24 21:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57403
Daniel Krügler <daniel.kruegler at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler@googlemail.
| |com
--- Comment #4 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
(In reply to Nick Maclaren from comment #2)
> That may well be true, but I can't find any such restriction in the C++
> standard. It would be a great help if the library specification weren't
> so ambiguous - in this case, it hinges around the meaning of the word
> 'type', and the unqualified word is used with at least three meanings
> in the standard.
Actually there is a miss in Table 27, where the variables T, U, and C are
described as
"any non-const object type (3.9)"
This should be corrected to
"any non-const non-volatile object type (3.9)"
I'm submitting an LWG issue for this.
>From gcc-bugs-return-423092-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri May 24 21:16:27 2013
Return-Path: <gcc-bugs-return-423092-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 750 invoked by alias); 24 May 2013 21:16: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 439 invoked by uid 48); 24 May 2013 21:16:23 -0000
From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/57406] New: [C++11] function templates don't accept function types with ref-qualifiers as template arguments
Date: Fri, 24 May 2013 21:16: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: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: daniel.kruegler at googlemail 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-57406-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-05/txt/msg01765.txt.bz2
Content-length: 1810
http://gcc.gnu.org/bugzilla/show_bug.cgi?idW406
Bug ID: 57406
Summary: [C++11] function templates don't accept function types
with ref-qualifiers as template arguments
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: daniel.kruegler at googlemail dot com
When attempting to update the library test cases that use the test_category
template I stumbled across compiler error that can be traced to the following
compiler test case:
The following code is rejected by gcc 4.9.0 20130519 (experimental) when
compiled with the flags
-std=c++11 -Wall -pedantic
//----------------------------------------
template<class T>
void foo() { }
int main()
{
foo<void() const>(); // OK
foo<void() &>(); // Error (line 7)
foo<void() const &&>(); // Error
}
//----------------------------------------
"main.cpp||In function 'int main()':|
main.cpp|7|error: parse error in template argument list|
main.cpp|7|error: no matching function for call to 'foo()'|
main.cpp|7|note: candidate is:|
main.cpp|2|note: template<class T> void foo()|
main.cpp|2|note: template argument deduction/substitution failed:|
main.cpp|7|error: template argument 1 is invalid|
main.cpp|8|error: parse error in template argument list|
main.cpp|8|error: no matching function for call to 'foo()'|
main.cpp|8|note: candidate is:|
main.cpp|2|note: template<class T> void foo()|
main.cpp|2|note: template argument deduction/substitution failed:|
||=== Build finished: 5 errors, 0 warnings (0 minutes, 0 seconds) ===|
"
The code should be accepted, such types are valid as template argument, as
specified by 8.3.5 p6 b5
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/57403] A vector of volatile int doesn't work, but one of volatile void * does
2013-05-24 18:41 [Bug libstdc++/57403] New: A vector of volatile int doesn't work, but one of volatile void * does nmm1 at cam dot ac.uk
` (3 preceding siblings ...)
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
5 siblings, 0 replies; 7+ messages in thread
From: nmm1 at cam dot ac.uk @ 2013-06-18 10:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57403
--- Comment #5 from Nick Maclaren <nmm1 at cam dot ac.uk> ---
Because of the last comment, I am not going to close this as resolved,
invalid, but please do so if appropriate.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/57403] A vector of volatile int doesn't work, but one of volatile void * does
2013-05-24 18:41 [Bug libstdc++/57403] New: A vector of volatile int doesn't work, but one of volatile void * does nmm1 at cam dot ac.uk
` (4 preceding siblings ...)
2013-06-18 10:39 ` nmm1 at cam dot ac.uk
@ 2014-10-13 14:40 ` redi at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-10-13 14:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57403
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The standard containers don't support volatile types.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-10-13 14:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-24 18:41 [Bug libstdc++/57403] New: A vector of volatile int doesn't work, but one of volatile void * does nmm1 at cam dot ac.uk
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
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).