0

The code below compiles without error using GCC 4.8.1 on Ubuntu 13.10 and Apple's Clang 5.0 (based on normal Clang 3.3) on Mac OS 10.9. However Clang 3.4 on the Ubuntu box spits out the following errors:

oz@MobileWolf:/prog/test$ clang++ -std=c++11 -c clangClass.cpp 
clangClass.cpp:24:7: error: 'CompilerError' attribute cannot be applied to types
class CompilerError : VirtualException, std::logic_error {
      ^
clangClass.cpp:24:7: error: 'CompilerError' attribute cannot be applied to types
class CompilerError : VirtualException, std::logic_error {
      ^
clangClass.cpp:24:7: error: 'CompilerError' attribute cannot be applied to types
class CompilerError : VirtualException, std::logic_error {
      ^
3 errors generated.

I've simplified the code as much as I could in hunting down the root cause of the error and I am no closer to understanding it. Simply substituting clang++ for g++ on the command line and the code compiles with no issue (even adding -Wall reveals nothing). I'm fine with using GCC for my project, I just like Clang's error messages better and don't understand why it is erroring in the first place.

#include <exception>
#include <stdexcept>
#include <string>

class VirtualException : public virtual std::exception {
protected:
    std::string m_message;

public:
    VirtualException( void ){}
    virtual ~VirtualException( void ){}
};

class Exception : public std::exception {
protected:
    std::string m_message;

public:
    Exception( void ){}
    virtual ~Exception( void ){}
};

class CompilerError : VirtualException, std::logic_error {
protected:
    CompilerError( void ): std::logic_error( "" ){}

public:
    CompilerError( const std::string& message ): std::logic_error( "" ){
        m_message   = message;
    }

    virtual ~CompilerError( void ) noexcept( true ){}
};

class NoError : Exception, std::logic_error {
protected:
    NoError( void ): std::logic_error( "" ){}

public:
    NoError( const std::string& message ): std::logic_error( "" ){
        m_message   = message;
    }

    virtual ~NoError( void ) noexcept( true ){}
};

Any help figuring out what Clang is choking on would be appreciated.

Oz.
  • 5,299
  • 2
  • 23
  • 30
  • [clang at Coliru](http://coliru.stacked-crooked.com/a/4f28c2fa82152af4) - not quite 3.4, but r184460 - compiles it ok. Are you on OSX by any chance? – Casey Dec 09 '13 at 04:28
  • @Casey I am not using a Mac for this. As I stated I am using Ubuntu 13.10. I haven't tested the code using Apple's version of Clang yet. – Oz. Dec 09 '13 at 20:40
  • @Casey, just tested it on OSX 10.9 with Apple's clang version 5.0 (3.3-based) and it compiles without a hitch. – Oz. Dec 09 '13 at 20:44
  • clang has its own e-mail forum. You can post this type of issue directly there. http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev – KeithSmith Dec 09 '13 at 21:00
  • @KeithSmith I'm in the process of filing a bug with them, but wanted to document the problem here as well in hopes someone might know of a solution, or in case I was making an error. – Oz. Dec 09 '13 at 22:08

0 Answers0