public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65218] New: [C++11] Complicated diagnostic of erroneous range expression over a pointer type
@ 2015-02-26 11:40 jgreenhalgh at gcc dot gnu.org
2015-09-15 10:18 ` [Bug c++/65218] " redi at gcc dot gnu.org
2021-12-16 22:34 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: jgreenhalgh at gcc dot gnu.org @ 2015-02-26 11:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65218
Bug ID: 65218
Summary: [C++11] Complicated diagnostic of erroneous range
expression over a pointer type
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jgreenhalgh at gcc dot gnu.org
Host: *-*-*
Target: *-*-*
Created attachment 34881
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34881&action=edit
Testcase to produce the diagnostic
For the attached testcase, the error is that foo has pointer-to-vector type and
so cannot be used in a range expression. However, foo points to a vector, which
can be used in a range expression, and it is likely that this is what the user
intended.
For the attached testcase, my Clang installation (3.5.0-development timescale)
prints:
foo.cpp:9:17: error: invalid range expression of type
'std::vector<std::pair<unsigned int, unsigned int> *> *'; did you mean to
dereference it with '*'?
for (auto i : foo)
^
*
1 error generated.
By contrast, GCC's diagnostic looks like this:
--------
foo.cpp: In function 'unsigned int bar()':
foo.cpp:9:17: error: no matching function for call to
'begin(std::vector<std::pair<unsigned int, unsigned int>*>*&)'
for (auto i : foo)
^
In file included from .../include/c++/5.0.0/vector:66:0,
from foo.cpp:1:
.../include/c++/5.0.0/bits/range_access.h:87:5: note: candidate: template<class
_Tp, long unsigned int _Nm> _Tp* std::begin(_Tp (&)[_Nm])
begin(_Tp (&__arr)[_Nm])
^
.../include/c++/5.0.0/bits/range_access.h:87:5: note: template argument
deduction/substitution failed:
foo.cpp:9:17: note: mismatched types '_Tp [_Nm]' and
'std::vector<std::pair<unsigned int, unsigned int>*>*'
for (auto i : foo)
^
In file included from .../include/c++/5.0.0/vector:66:0,
from foo.cpp:1:
.../include/c++/5.0.0/bits/range_access.h:58:5: note: candidate: template<class
_Container> decltype (__cont.begin()) std::begin(const _Container&)
begin(const _Container& __cont) -> decltype(__cont.begin())
^
.../include/c++/5.0.0/bits/range_access.h:58:5: note: template argument
deduction/substitution failed:
.../include/c++/5.0.0/bits/range_access.h: In substitution of 'template<class
_Container> decltype (__cont.begin()) std::begin(const _Container&) [with
_Container = std::vector<std::pair<unsigned int, unsigned int>*>*]':
foo.cpp:9:17: required from here
.../include/c++/5.0.0/bits/range_access.h:58:5: error: request for member
'begin' in '__cont', which is of pointer type 'std::vector<std::pair<unsigned
int, unsigned int>*>* const' (maybe you meant to use '->' ?)
.../include/c++/5.0.0/bits/range_access.h:48:5: note: candidate: template<class
_Container> decltype (__cont.begin()) std::begin(_Container&)
begin(_Container& __cont) -> decltype(__cont.begin())
^
.../include/c++/5.0.0/bits/range_access.h:48:5: note: template argument
deduction/substitution failed:
.../include/c++/5.0.0/bits/range_access.h: In substitution of 'template<class
_Container> decltype (__cont.begin()) std::begin(_Container&) [with _Container
= std::vector<std::pair<unsigned int, unsigned int>*>*]':
foo.cpp:9:17: required from here
.../include/c++/5.0.0/bits/range_access.h:48:5: error: request for member
'begin' in '__cont', which is of pointer type 'std::vector<std::pair<unsigned
int, unsigned int>*>*' (maybe you meant to use '->' ?)
In file included from .../include/c++/5.0.0/bits/stl_vector.h:63:0,
from .../include/c++/5.0.0/vector:64,
from foo.cpp:1:
.../include/c++/5.0.0/initializer_list:89:5: note: candidate: template<class
_Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)
begin(initializer_list<_Tp> __ils) noexcept
^
.../include/c++/5.0.0/initializer_list:89:5: note: template argument
deduction/substitution failed:
foo.cpp:9:17: note: mismatched types 'std::initializer_list<_Tp>' and
'std::vector<std::pair<unsigned int, unsigned int>*>*'
for (auto i : foo)
^
foo.cpp:9:17: error: no matching function for call to
'end(std::vector<std::pair<unsigned int, unsigned int>*>*&)'
In file included from .../include/c++/5.0.0/vector:66:0,
from foo.cpp:1:
.../include/c++/5.0.0/bits/range_access.h:97:5: note: candidate: template<class
_Tp, long unsigned int _Nm> _Tp* std::end(_Tp (&)[_Nm])
end(_Tp (&__arr)[_Nm])
^
.../include/c++/5.0.0/bits/range_access.h:97:5: note: template argument
deduction/substitution failed:
foo.cpp:9:17: note: mismatched types '_Tp [_Nm]' and
'std::vector<std::pair<unsigned int, unsigned int>*>*'
for (auto i : foo)
^
In file included from .../include/c++/5.0.0/vector:66:0,
from foo.cpp:1:
.../include/c++/5.0.0/bits/range_access.h:78:5: note: candidate: template<class
_Container> decltype (__cont.end()) std::end(const _Container&)
end(const _Container& __cont) -> decltype(__cont.end())
^
.../include/c++/5.0.0/bits/range_access.h:78:5: note: template argument
deduction/substitution failed:
.../include/c++/5.0.0/bits/range_access.h: In substitution of 'template<class
_Container> decltype (__cont.end()) std::end(const _Container&) [with
_Container = std::vector<std::pair<unsigned int, unsigned int>*>*]':
foo.cpp:9:17: required from here
.../include/c++/5.0.0/bits/range_access.h:78:5: error: request for member 'end'
in '__cont', which is of pointer type 'std::vector<std::pair<unsigned int,
unsigned int>*>* const' (maybe you meant to use '->' ?)
.../include/c++/5.0.0/bits/range_access.h:68:5: note: candidate: template<class
_Container> decltype (__cont.end()) std::end(_Container&)
end(_Container& __cont) -> decltype(__cont.end())
^
.../include/c++/5.0.0/bits/range_access.h:68:5: note: template argument
deduction/substitution failed:
.../include/c++/5.0.0/bits/range_access.h: In substitution of 'template<class
_Container> decltype (__cont.end()) std::end(_Container&) [with _Container =
std::vector<std::pair<unsigned int, unsigned int>*>*]':
foo.cpp:9:17: required from here
.../include/c++/5.0.0/bits/range_access.h:68:5: error: request for member 'end'
in '__cont', which is of pointer type 'std::vector<std::pair<unsigned int,
unsigned int>*>*' (maybe you meant to use '->' ?)
In file included from .../include/c++/5.0.0/bits/stl_vector.h:63:0,
from .../include/c++/5.0.0/vector:64,
from foo.cpp:1:
.../include/c++/5.0.0/initializer_list:99:5: note: candidate: template<class
_Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
end(initializer_list<_Tp> __ils) noexcept
^
.../include/c++/5.0.0/initializer_list:99:5: note: template argument
deduction/substitution failed:
foo.cpp:9:17: note: mismatched types 'std::initializer_list<_Tp>' and
'std::vector<std::pair<unsigned int, unsigned int>*>*'
for (auto i : foo)
^
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/65218] [C++11] Complicated diagnostic of erroneous range expression over a pointer type
2015-02-26 11:40 [Bug c++/65218] New: [C++11] Complicated diagnostic of erroneous range expression over a pointer type jgreenhalgh at gcc dot gnu.org
@ 2015-09-15 10:18 ` redi at gcc dot gnu.org
2021-12-16 22:34 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-15 10:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65218
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-09-15
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/65218] [C++11] Complicated diagnostic of erroneous range expression over a pointer type
2015-02-26 11:40 [Bug c++/65218] New: [C++11] Complicated diagnostic of erroneous range expression over a pointer type jgreenhalgh at gcc dot gnu.org
2015-09-15 10:18 ` [Bug c++/65218] " redi at gcc dot gnu.org
@ 2021-12-16 22:34 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-16 22:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65218
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2015-09-15 00:00:00 |2021-12-16
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
<source>: In function 'unsigned int bar()':
<source>:9:17: error: no matching function for call to
'begin(std::vector<std::pair<unsigned int, unsigned int>*>*&)'
9 | for (auto i : foo)
| ^~~
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-16 22:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-26 11:40 [Bug c++/65218] New: [C++11] Complicated diagnostic of erroneous range expression over a pointer type jgreenhalgh at gcc dot gnu.org
2015-09-15 10:18 ` [Bug c++/65218] " redi at gcc dot gnu.org
2021-12-16 22:34 ` pinskia 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).