public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/44122] New: Confusing error: cannot convert 'T* to T*
@ 2010-05-13 18:53 ppluzhnikov at google dot com
2010-05-15 0:16 ` [Bug c++/44122] Confusing error: cannot convert 'T*' to 'T*' manu at gcc dot gnu dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: ppluzhnikov at google dot com @ 2010-05-13 18:53 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1036 bytes --]
Here is the complete error message:
g++ -c t.cc
t.cc: In function int bar():
t.cc:8:18: error: cannot convert Py_ssize_t* to Py_ssize_t* for argument
1 to int foo(Py_ssize_t*)
How is that even possible?
cat t.cc
typedef long Py_ssize_t;
int foo(Py_ssize_t *);
int bar() {
typedef int Py_ssize_t;
Py_ssize_t pos;
return foo(&pos);
}
Suggested improvement:
t.cc:8: error: cannot convert '{bar}::Py_ssize_t* [int*]' to 'Py_ssize_t*
[long*]' for 1st argument to 'int foo(Py_ssize_t*)'
--
Summary: Confusing error: cannot convert 'T* to T*
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ppluzhnikov at google dot com
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44122
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/44122] Confusing error: cannot convert 'T*' to 'T*'
2010-05-13 18:53 [Bug c++/44122] New: Confusing error: cannot convert 'T* to T* ppluzhnikov at google dot com
@ 2010-05-15 0:16 ` manu at gcc dot gnu dot org
2010-05-15 0:47 ` redi at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-05-15 0:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from manu at gcc dot gnu dot org 2010-05-15 00:16 -------
Have you tried with Clang?
I think Clang prints typedefs using 'aka', which is not very clear.
error: incompatible type assigning 'vector<Real>', expected 'std::string' (aka
'class std::basic_string<char>')
I would suggest:
t.cc:8: error: cannot convert 'bar::Py_ssize_t*' ('int*') to 'Py_ssize_t*'
('long*') for 1st argument to 'int foo(Py_ssize_t*)'
Do we have typedef unwrapping?
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-05-15 00:16:20
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44122
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/44122] Confusing error: cannot convert 'T*' to 'T*'
2010-05-13 18:53 [Bug c++/44122] New: Confusing error: cannot convert 'T* to T* ppluzhnikov at google dot com
2010-05-15 0:16 ` [Bug c++/44122] Confusing error: cannot convert 'T*' to 'T*' manu at gcc dot gnu dot org
@ 2010-05-15 0:47 ` redi at gcc dot gnu dot org
2010-05-15 0:55 ` manu at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu dot org @ 2010-05-15 0:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from redi at gcc dot gnu dot org 2010-05-15 00:47 -------
(In reply to comment #1)
> Have you tried with Clang?
>
> I think Clang prints typedefs using 'aka', which is not very clear.
>
> error: incompatible type assigning 'vector<Real>', expected 'std::string' (aka
> 'class std::basic_string<char>')
>
> I would suggest:
>
> t.cc:8: error: cannot convert 'bar::Py_ssize_t*' ('int*') to 'Py_ssize_t*'
> ('long*') for 1st argument to 'int foo(Py_ssize_t*)'
1) bar:: looks like valid C++ syntax but it is not a valid
nested-name-specifier, so it should be something that is not valid C++ syntax,
such as {bar}::Py_ssize_t
2) Although the quotes _should_ make it clear, I think that could get confusing
when the type involves parentheses, e.g.
cannot convert 'my_fun_type' ('int* (Foo::*)(char*)') to 'int* const
(Foo::*)(char*)'
How about adding "typedef for" in there? e.g.
cannot convert 'bar::Py_ssize_t*' (typedef for 'int*')
> Do we have typedef unwrapping?
We used to only have unwrapped typedefs, so hopefully we can still get it when
wanted!
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44122
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/44122] Confusing error: cannot convert 'T*' to 'T*'
2010-05-13 18:53 [Bug c++/44122] New: Confusing error: cannot convert 'T* to T* ppluzhnikov at google dot com
2010-05-15 0:16 ` [Bug c++/44122] Confusing error: cannot convert 'T*' to 'T*' manu at gcc dot gnu dot org
2010-05-15 0:47 ` redi at gcc dot gnu dot org
@ 2010-05-15 0:55 ` manu at gcc dot gnu dot org
2010-05-15 0:59 ` ppluzhnikov at google dot com
2010-07-24 21:17 ` [Bug c++/44122] Confusing error: cannot convert 'T*' to 'T*' (when T are different scopes) pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-05-15 0:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from manu at gcc dot gnu dot org 2010-05-15 00:55 -------
(In reply to comment #2)
>
> 1) bar:: looks like valid C++ syntax but it is not a valid
> nested-name-specifier, so it should be something that is not valid C++ syntax,
> such as {bar}::Py_ssize_t
True, but {bar}:: is still confusing. If someone does a patch with that, so be
it, but I would prefer a different syntax. Or even two extra notes like:
t.cc: 7: note: 'Py_ssize_t*' (typedef for 'int*') defined here.
t.cc: 1: note: 'Py_ssize_t*' (typedef for 'long*') defined here.
so it is easy to jump to the definitions.
> 2) Although the quotes _should_ make it clear, I think that could get confusing
>
> How about adding "typedef for" in there? e.g.
>
> cannot convert 'bar::Py_ssize_t*' (typedef for 'int*')
Perfect!
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44122
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/44122] Confusing error: cannot convert 'T*' to 'T*'
2010-05-13 18:53 [Bug c++/44122] New: Confusing error: cannot convert 'T* to T* ppluzhnikov at google dot com
` (2 preceding siblings ...)
2010-05-15 0:55 ` manu at gcc dot gnu dot org
@ 2010-05-15 0:59 ` ppluzhnikov at google dot com
2010-07-24 21:17 ` [Bug c++/44122] Confusing error: cannot convert 'T*' to 'T*' (when T are different scopes) pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: ppluzhnikov at google dot com @ 2010-05-15 0:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from ppluzhnikov at google dot com 2010-05-15 00:59 -------
For reference, here is what clang currently prints (I am told):
t.cc:8:9: error: no matching function for call to 'foo'
return foo(&pos);
^~~
t.cc:3:5: note: candidate function not viable: no known conversion from
'Py_ssize_t *' (aka 'int *') to 'Py_ssize_t *' (aka 'long *') for 1st argument
int foo(Py_ssize_t *);
^
1 error generated.
I do like both the 'typedef for', and the extra notes ideas.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44122
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/44122] Confusing error: cannot convert 'T*' to 'T*' (when T are different scopes)
2010-05-13 18:53 [Bug c++/44122] New: Confusing error: cannot convert 'T* to T* ppluzhnikov at google dot com
` (3 preceding siblings ...)
2010-05-15 0:59 ` ppluzhnikov at google dot com
@ 2010-07-24 21:17 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-07-24 21:17 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
GCC build triplet|x86_64-unknown-linux-gnu |
GCC host triplet|x86_64-unknown-linux-gnu |
GCC target triplet|x86_64-unknown-linux-gnu |
Summary|Confusing error: cannot |Confusing error: cannot
|convert 'T*' to 'T*' |convert 'T*' to 'T*' (when T
| |are different scopes)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44122
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-07-24 21:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-13 18:53 [Bug c++/44122] New: Confusing error: cannot convert 'T* to T* ppluzhnikov at google dot com
2010-05-15 0:16 ` [Bug c++/44122] Confusing error: cannot convert 'T*' to 'T*' manu at gcc dot gnu dot org
2010-05-15 0:47 ` redi at gcc dot gnu dot org
2010-05-15 0:55 ` manu at gcc dot gnu dot org
2010-05-15 0:59 ` ppluzhnikov at google dot com
2010-07-24 21:17 ` [Bug c++/44122] Confusing error: cannot convert 'T*' to 'T*' (when T are different scopes) 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).