public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "d.frey at gmx dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/56468] New: Clang exposes bug with unexpected forward-declaration of type_info
Date: Tue, 26 Feb 2013 22:50:00 -0000	[thread overview]
Message-ID: <bug-56468-4@http.gcc.gnu.org/bugzilla/> (raw)


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>.


             reply	other threads:[~2013-02-26 22:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-26 22:50 d.frey at gmx dot de [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-56468-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).