[cfe-dev] clang++ redeclaration error and segfault

Richtarsky, Martin martin.richtarsky at sap.com
Mon Mar 19 04:49:28 PDT 2012


Hello,

I am currently trying to get a rather large C++ project to build on clang++. After some changes, it is looking quite good. However, on one file I encountered a segfault with LLVM/clang 3.0. Therefore, I checked out the latest version from SVN yesterday and tested with a Debug+Asserts build. This is running in another problem on a different .cpp file which clang 3.0 can successfully compile.


In file included from /local/build/git3/sys/src/ptime/query/catalog/metadata_context.cc:1:
In file included from /local/build/git3/sys/src/ptime/query/catalog/metadata_context.h:6:
In file included from /local/build/git3/sys/src/ptime/query/catalog/ct_def.h:34:
In file included from /local/build/git3/sys/src/ptime/common/datatype/datatype.h:28:
In file included from /local/build/git3/sys/src/Expression/Dictionary/Dictionary.h:4:
In file included from /local/build/git3/sys/src/Expression/Dictionary/Description.h:35:
/local/build/git3/sys/src/ptime/common/util/link_hash.h:247:3: error: constructor cannot be redeclared
                Bin();
                ^
/local/build/git3/sys/src/ptime/common/util/link_hash.h:312:46: note: in instantiation of member class 'ptime::LinkHash<ltt_adp::basic_string<char, ltt::char_traits<char>, ltt::true_type>, ptime::NameLock::POSIX_COND_AND_MUTEX *, 509, 8>::Bin' requested here
                ptime_byte for_cacheline[P_CACHE_LINE_SIZE - BIN_SIZE];
                                                           ^
/local/build/git3/sys/src/ptime/common/util/link_hash.h:320:6: note: in instantiation of member class 'ptime::LinkHash<ltt_adp::basic_string<char, ltt::char_traits<char>, ltt::true_type>, ptime::NameLock::POSIX_COND_AND_MUTEX *, 509, 8>::Bin' requested here
        Bin bins[FANOUT];
            ^
/local/build/git3/sys/src/ptime/common/util/namelock.h:47:52: note: in instantiation of template class 'ptime::LinkHash<ltt_adp::basic_string<char, ltt::char_traits<char>, ltt::true_type>, ptime::NameLock::POSIX_COND_AND_MUTEX *, 509, 8>' requested here
    LinkHash<_STL::string, POSIX_COND_AND_MUTEX *> nameLockMap;
                                                   ^
/local/build/git3/sys/src/ptime/common/util/link_hash.h:247:3: note: previous declaration is here
                Bin();
                ^

...[some more redeclaration errors omitted]

/local/build/git3/sys/src/ptime/common/util/link_hash.h:283:12: note: previous declaration is here
fatal error: too many errors emitted, stopping now [-ferror-limit=]
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang: note: diagnostic msg: Please submit a bug report to http://llvm.org/bugs/ and include command line arguments and all diagnostic information.
clang: note: diagnostic msg: Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /local/build/git3/tmp/metadata_context-01e1fJ.ii
clang: note: diagnostic msg: /local/build/git3/tmp/metadata_context-01e1fJ.sh


The header file link_hash.h  has include guards. The preprocessed file contains for example

template <class A, class B, class C, class D>
class LinkHash

 class Bin
 {
 public:
  Bin();
  ~Bin();
}

and later the definition

template <class A, class B, unsigned C, unsigned D>
LinkHash<A, B, C, D>::Bin::~Bin()
{
 delete [] dir_;
 dir_= 0;
}


I tried to put the complete definition in the class definition, but the same error showed up.

Any idea what changed in clang-trunk that could make this fail?

Best regards,
Martin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120319/f2326e87/attachment.html>


More information about the cfe-dev mailing list