public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/56468] New: Clang exposes bug with unexpected forward-declaration of type_info
@ 2013-02-26 22:50 d.frey at gmx dot de
2013-02-26 23:22 ` [Bug libstdc++/56468] " redi at gcc dot gnu.org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: d.frey at gmx dot de @ 2013-02-26 22:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56468
Bug #: 56468
Summary: Clang exposes bug with unexpected forward-declaration
of type_info
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: d.frey@gmx.de
The following program fails to compile with Clang++ 3.2:
#include <typeinfo>
#include <exception>
const char* get_name( const std::exception_ptr eptr )
{
return eptr.__cxa_exception_type()->name();
}
int main() {}
The output in the shell is:
$ g++-4.7 -std=c++0x -O3 -Wall -Wextra t.cc -o t
$ clang++-3.2 -std=c++0x -O3 -Wall -Wextra t.cc -o t
t.cc:6:37: error: member access into incomplete type 'const class type_info'
return eptr.__cxa_exception_type()->name();
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/exception_ptr.h:144:19:
note: forward declaration of
'std::__exception_ptr::type_info'
const class type_info*
^
1 error generated.
$
The problem is that <typeinfo> includes <exception> before it forward-declares
std::type_info. In <exception>, type_info is used in the context of
std::__exception_ptr, thus Clang generates an implicit forward-declaration for
std::__exception_ptr::type_info and, when used in the above code, consequently
fails.
Further discussion has taken place at <http://stackoverflow.com/q/15098174>.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libstdc++/56468] Clang exposes bug with unexpected forward-declaration of type_info
2013-02-26 22:50 [Bug libstdc++/56468] New: Clang exposes bug with unexpected forward-declaration of type_info d.frey at gmx dot de
@ 2013-02-26 23:22 ` redi at gcc dot gnu.org
2013-02-27 7:36 ` jakub at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2013-02-26 23:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56468
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-02-26
Ever Confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-02-26 23:22:23 UTC ---
Something like this should fix it
--- a/libstdc++-v3/libsupc++/exception_ptr.h
+++ b/libstdc++-v3/libsupc++/exception_ptr.h
@@ -44,6 +44,8 @@ extern "C++" {
namespace std
{
+ class type_info;
+
/**
* @addtogroup exceptions
* @{
@@ -141,7 +143,7 @@ namespace std
operator==(const exception_ptr&, const exception_ptr&)
_GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
- const class type_info*
+ const std::type_info*
__cxa_exception_type() const _GLIBCXX_USE_NOEXCEPT
__attribute__ ((__pure__));
};
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libstdc++/56468] Clang exposes bug with unexpected forward-declaration of type_info
2013-02-26 22:50 [Bug libstdc++/56468] New: Clang exposes bug with unexpected forward-declaration of type_info d.frey at gmx dot de
2013-02-26 23:22 ` [Bug libstdc++/56468] " redi at gcc dot gnu.org
@ 2013-02-27 7:36 ` jakub at gcc dot gnu.org
2013-02-27 9:34 ` redi at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-02-27 7:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56468
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |jason at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-02-27 07:35:56 UTC ---
Is that something g++ should diagnose too?
Or is this because init_rtti_processing forward declares std::type_info class
automatically?
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libstdc++/56468] Clang exposes bug with unexpected forward-declaration of type_info
2013-02-26 22:50 [Bug libstdc++/56468] New: Clang exposes bug with unexpected forward-declaration of type_info d.frey at gmx dot de
2013-02-26 23:22 ` [Bug libstdc++/56468] " redi at gcc dot gnu.org
2013-02-27 7:36 ` jakub at gcc dot gnu.org
@ 2013-02-27 9:34 ` redi at gcc dot gnu.org
2013-02-28 16:15 ` d.frey at gmx dot de
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2013-02-27 9:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56468
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-02-27 09:33:27 UTC ---
It's because of the implicit declaration of std::type_info, G++ correctly
diagnoses similar cases with altered namespace names or type names, it only
happens for std::type_info. I see no harm in adding an explicit declaration to
the libstdc++ header so it works with clang and other compilers that don't
declare std::type_info automatically.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libstdc++/56468] Clang exposes bug with unexpected forward-declaration of type_info
2013-02-26 22:50 [Bug libstdc++/56468] New: Clang exposes bug with unexpected forward-declaration of type_info d.frey at gmx dot de
` (2 preceding siblings ...)
2013-02-27 9:34 ` redi at gcc dot gnu.org
@ 2013-02-28 16:15 ` d.frey at gmx dot de
2013-03-16 20:02 ` redi at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: d.frey at gmx dot de @ 2013-02-28 16:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56468
--- Comment #4 from Daniel Frey <d.frey at gmx dot de> 2013-02-28 16:14:41 UTC ---
(In reply to comment #1)
I think the first line you added is enough, as evidenced by my "fix" referenced
in the Stack Overflow discussion (see link above). But the second line won't
hurt either.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libstdc++/56468] Clang exposes bug with unexpected forward-declaration of type_info
2013-02-26 22:50 [Bug libstdc++/56468] New: Clang exposes bug with unexpected forward-declaration of type_info d.frey at gmx dot de
` (3 preceding siblings ...)
2013-02-28 16:15 ` d.frey at gmx dot de
@ 2013-03-16 20:02 ` redi at gcc dot gnu.org
2013-03-16 20:23 ` redi at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2013-03-16 20:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56468
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-03-16 20:01:27 UTC ---
Author: redi
Date: Sat Mar 16 20:01:16 2013
New Revision: 196709
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196709
Log:
PR libstdc++/56468
* libsupc++/exception_ptr.h (type_info): Declare.
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/libsupc++/exception_ptr.h
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libstdc++/56468] Clang exposes bug with unexpected forward-declaration of type_info
2013-02-26 22:50 [Bug libstdc++/56468] New: Clang exposes bug with unexpected forward-declaration of type_info d.frey at gmx dot de
` (4 preceding siblings ...)
2013-03-16 20:02 ` redi at gcc dot gnu.org
@ 2013-03-16 20:23 ` redi at gcc dot gnu.org
2013-03-16 20:24 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2013-03-16 20:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56468
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-03-16 20:22:57 UTC ---
Author: redi
Date: Sat Mar 16 20:22:40 2013
New Revision: 196711
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196711
Log:
PR libstdc++/56468
* libsupc++/exception_ptr.h (type_info): Declare.
Modified:
branches/gcc-4_7-branch/libstdc++-v3/ChangeLog
branches/gcc-4_7-branch/libstdc++-v3/libsupc++/exception_ptr.h
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libstdc++/56468] Clang exposes bug with unexpected forward-declaration of type_info
2013-02-26 22:50 [Bug libstdc++/56468] New: Clang exposes bug with unexpected forward-declaration of type_info d.frey at gmx dot de
` (5 preceding siblings ...)
2013-03-16 20:23 ` redi at gcc dot gnu.org
@ 2013-03-16 20:24 ` redi at gcc dot gnu.org
2013-03-16 23:46 ` steven at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2013-03-16 20:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56468
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |redi at gcc dot gnu.org
|gnu.org |
Target Milestone|--- |4.7.3
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-03-16 20:23:58 UTC ---
Fixed on trunk and 4.7 branch so far, the fix will also be done for 4.8.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libstdc++/56468] Clang exposes bug with unexpected forward-declaration of type_info
2013-02-26 22:50 [Bug libstdc++/56468] New: Clang exposes bug with unexpected forward-declaration of type_info d.frey at gmx dot de
` (6 preceding siblings ...)
2013-03-16 20:24 ` redi at gcc dot gnu.org
@ 2013-03-16 23:46 ` steven at gcc dot gnu.org
2013-03-17 11:36 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: steven at gcc dot gnu.org @ 2013-03-16 23:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56468
--- Comment #8 from Steven Bosscher <steven at gcc dot gnu.org> 2013-03-16 23:46:08 UTC ---
(In reply to comment #7)
> Fixed on trunk and 4.7 branch so far, the fix will also be done for 4.8.1
It's unusual for a bug to be fixed for a previous release and for trunk,
but not on the latest release. Isn't this worth applying to GCC 4.8.0
also? The patch looks safe and simple enough...
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libstdc++/56468] Clang exposes bug with unexpected forward-declaration of type_info
2013-02-26 22:50 [Bug libstdc++/56468] New: Clang exposes bug with unexpected forward-declaration of type_info d.frey at gmx dot de
` (7 preceding siblings ...)
2013-03-16 23:46 ` steven at gcc dot gnu.org
@ 2013-03-17 11:36 ` jakub at gcc dot gnu.org
2013-03-17 14:11 ` redi at gcc dot gnu.org
2013-03-17 14:12 ` redi at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-03-17 11:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56468
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-03-17 11:35:55 UTC ---
Yeah, I think this patch is fine even for 4.8.0, and there is no need to do
another RC for that.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libstdc++/56468] Clang exposes bug with unexpected forward-declaration of type_info
2013-02-26 22:50 [Bug libstdc++/56468] New: Clang exposes bug with unexpected forward-declaration of type_info d.frey at gmx dot de
` (8 preceding siblings ...)
2013-03-17 11:36 ` jakub at gcc dot gnu.org
@ 2013-03-17 14:11 ` redi at gcc dot gnu.org
2013-03-17 14:12 ` redi at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2013-03-17 14:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56468
--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-03-17 14:10:46 UTC ---
Author: redi
Date: Sun Mar 17 14:10:39 2013
New Revision: 196749
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196749
Log:
PR libstdc++/56468
* libsupc++/exception_ptr.h (type_info): Declare.
Modified:
branches/gcc-4_8-branch/libstdc++-v3/ChangeLog
branches/gcc-4_8-branch/libstdc++-v3/libsupc++/exception_ptr.h
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libstdc++/56468] Clang exposes bug with unexpected forward-declaration of type_info
2013-02-26 22:50 [Bug libstdc++/56468] New: Clang exposes bug with unexpected forward-declaration of type_info d.frey at gmx dot de
` (9 preceding siblings ...)
2013-03-17 14:11 ` redi at gcc dot gnu.org
@ 2013-03-17 14:12 ` redi at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2013-03-17 14:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56468
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-03-17 14:11:44 UTC ---
OK, thanks, guys, this is done then.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-03-17 14:12 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-26 22:50 [Bug libstdc++/56468] New: Clang exposes bug with unexpected forward-declaration of type_info d.frey at gmx dot de
2013-02-26 23:22 ` [Bug libstdc++/56468] " redi at gcc dot gnu.org
2013-02-27 7:36 ` jakub at gcc dot gnu.org
2013-02-27 9:34 ` redi at gcc dot gnu.org
2013-02-28 16:15 ` d.frey at gmx dot de
2013-03-16 20:02 ` redi at gcc dot gnu.org
2013-03-16 20:23 ` redi at gcc dot gnu.org
2013-03-16 20:24 ` redi at gcc dot gnu.org
2013-03-16 23:46 ` steven at gcc dot gnu.org
2013-03-17 11:36 ` jakub at gcc dot gnu.org
2013-03-17 14:11 ` redi at gcc dot gnu.org
2013-03-17 14:12 ` 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).