public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48980] New: Misleading error message when a conversion is invalid while calling a protected base constructor
@ 2011-05-12 16:03 dibeas at ieee dot org
2011-05-12 16:33 ` [Bug c++/48980] " redi at gcc dot gnu.org
2011-07-24 20:19 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: dibeas at ieee dot org @ 2011-05-12 16:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48980
Summary: Misleading error message when a conversion is invalid
while calling a protected base constructor
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: trivial
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: dibeas@ieee.org
Provided with this code:
class base {
protected:
base( int * ) {}
};
struct derived : base {
derived( const int * p ) : base( p ) {}
};
The compiler correctly detects that there is an error as using p as argument to
the constructor of base will break const-correctness. The error report
identifies that condition, but it also adds a misleading first error:
error.cpp: In constructor ‘derived::derived(const int*)’:
error.cpp:5: error: ‘base::base(int*)’ is protected
error.cpp:10: error: within this context
error.cpp:10: error: invalid conversion from ‘const int*’ to ‘int*’
error.cpp:10: error: initializing argument 1 of ‘base::base(int*)’
Clearly base::base(int*) is protected, but it is accessible from the context of
the constructor derived::derived(const int*), and the first 3 lines should not
be part of the error message.
This can be reproduced with the default g++ in ubuntu/linaro, and also with g++
4.0.3 (I don't know the exact compiler flags used, but I believe the error to
be independent of compiler flags, if it is not, I can find out the exact flags
used).
g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/48980] Misleading error message when a conversion is invalid while calling a protected base constructor
2011-05-12 16:03 [Bug c++/48980] New: Misleading error message when a conversion is invalid while calling a protected base constructor dibeas at ieee dot org
@ 2011-05-12 16:33 ` redi at gcc dot gnu.org
2011-07-24 20:19 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-12 16:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48980
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-12 15:58:06 UTC ---
With 4.6 you just get:
d.cc: In constructor 'derived::derived(const int*)':
d.cc:6:39: error: invalid conversion from 'const int*' to 'int*' [-fpermissive]
d.cc:3:4: error: initializing argument 1 of 'base::base(int*)' [-fpermissive]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/48980] Misleading error message when a conversion is invalid while calling a protected base constructor
2011-05-12 16:03 [Bug c++/48980] New: Misleading error message when a conversion is invalid while calling a protected base constructor dibeas at ieee dot org
2011-05-12 16:33 ` [Bug c++/48980] " redi at gcc dot gnu.org
@ 2011-07-24 20:19 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-07-24 20:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48980
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.6.0
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-07-24 20:18:33 UTC ---
Fixed in 4.6.0 and above.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-07-24 20:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-12 16:03 [Bug c++/48980] New: Misleading error message when a conversion is invalid while calling a protected base constructor dibeas at ieee dot org
2011-05-12 16:33 ` [Bug c++/48980] " redi at gcc dot gnu.org
2011-07-24 20:19 ` 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).