Bug 38002 - gcc crash using -fvisibility-ms-compat
Summary: gcc crash using -fvisibility-ms-compat
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.2
: P3 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: ice-on-valid-code
Depends on:
Reported: 2008-11-03 14:56 UTC by Bogdan Slusarczyk
Modified: 2010-07-30 19:01 UTC (History)
5 users (show)

See Also:
Known to work:
Known to fail: 4.3.0
Last reconfirmed: 2008-11-03 16:42:14

preprocessor output (75.01 KB, text/plain)
2008-11-03 14:58 UTC, Bogdan Slusarczyk
Proposed patch (287 bytes, patch)
2009-10-27 16:22 UTC, Steve Little
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bogdan Slusarczyk 2008-11-03 14:56:57 UTC
gcc version 4.3.2 (GCC)
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.3.2/configure --prefix=/usr/local/gcc-4.3.2 --enable-languages=c,c++ --with-gmp=/home/builder/4gcc43 --with-mpfr=/home/builder/4gcc43 --with-as=/usr/local/gcc-4.3.2/bin/as --with-gnu-as --with-ld=/usr/local/gcc-4.3.2/bin/ld --with-gnu-ld
Thread model: posix

system: Linux, Debian, 2.6.25

third party libraries: boost 1.33.1

command line: gcc error.cpp -I. -shared -o error.so -fvisibility-ms-compat -lstdc++ -I$BOOST_INCLUDE_DIR -save-temps 

gcc output:

/usr/local/gcc-4.3.2/boost_1_33_1/include/boost/lexical_cast.hpp: In instantiation of 'Target boost::lexical_cast(const Source&) [with Target = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Source = int*]':
error.cpp:6:   instantiated from here
/usr/local/gcc-4.3.2/boost_1_33_1/include/boost/lexical_cast.hpp:223: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

How to attach *.ii file???
Comment 1 Bogdan Slusarczyk 2008-11-03 14:58:33 UTC
Created attachment 16618 [details]
preprocessor output
Comment 2 Richard Biener 2008-11-03 16:07:56 UTC
Comment 3 Richard Biener 2008-11-03 16:42:14 UTC
Reduced testcase, not a regression.

namespace std __attribute__ ((__visibility__ ("default"))) {
    class type_info   { };
template<class E> 
void throw_exception(E const & e);
class bad_lexical_cast {
    bad_lexical_cast(const std::type_info &target_type);
template<typename Source> 
int lexical_cast(const Source &arg)
int i;
int test = lexical_cast( &i );
Comment 4 Steve Little 2009-10-26 17:39:28 UTC
(In reply to comment #3)
> Reduced testcase, not a regression.

Here's a further reduction which still reproduces the crash:

namespace std __attribute__ ((__visibility__ ("default"))) {
    class type_info   { };

void foo() {
  int i;
Comment 5 Steve Little 2009-10-27 16:22:02 UTC
Created attachment 18917 [details]
Proposed patch

Looks like all we were missing was a check on CLASS_TYPE_P before calling CLASSTYPE_VISIBILITY_SPECIFIED.

This seems to fix the crash, at least for me.
Comment 6 Jack Marr 2010-07-30 19:01:51 UTC
(In reply to comment #5)

Apple seems to have fixed it a different way:


      tree underlying_type = TREE_TYPE (DECL_NAME (decl));
      int underlying_vis = type_visibility (underlying_type);
      if (underlying_vis == VISIBILITY_ANON
          /* APPLE LOCAL begin 6983171 */
          || (TREE_CODE (underlying_type) == RECORD_TYPE
          && CLASSTYPE_VISIBILITY_SPECIFIED (underlying_type)))
          /* APPLE LOCAL end 6983171 */
        constrain_visibility (decl, underlying_vis);

I知 not sure which approach is better.