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.