Re: [eigen] Dynamic exception specifications are deprecated in C++11 mode and other warnings

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Il giorno 23/ago/2014, alle ore 14:16, Moritz Klammler <moritz@xxxxxxxxxxx> ha scritto:

> 
>> I would like to add the attribute to the function.  Note that
>> [[noreturn]] is a C++11 attribute syntax, but on clang and g++ (and
>> ICC, I suppose) it is the same as __attribute__((noreturn)) which is
>> supported and could be useful also in C++98 mode.
>> Do you have a feature test macro in eigen for the support of the
>> noreturn attribute?  If not, do you have a feature test macro for
>> GNU-like compilers?
> 
> I did not understand from your message whether you are working on a
> header-only library that uses Eigen as part of it or are compiling Eigen
> into the source code of whatever.  In the second case, if you are using
> the GNU Autotools, you can use the macro `AX_GCC_FUNC_ATTRIBUTE` from
> the Autoconf macro archive:
> 
>    https://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html#ax_gcc_func_attribute
> 
> In your `configure.ac`, add
> 
>    AX_GCC_FUNC_ATTRIBUTE(noreturn)
> 
> and in your source code
> 
>    #include <config.h>
>    #if HAVE_FUNC_ATTRIBUTE_NORETURN
>    #  define MY_NORETURN __attribute__((noreturn))
>    #else
>    #  define MY_NORETURN /* empty */
>    #endif
> 

These are warnings from Eigen sources, so I'd like to add the check to Eigen, not 
to my sources. What I would like to do is to patch Eigen to silence that warning
by adding the attribute to the throw_std_bad_alloc() function.
Since Eigen is header-only I have to find a way to check the availability of the
attribute without external configuration tools. I think testing for __GNUC__ is
sufficient as any gnu-compatible compiler has that syntax for attributes, and 
I don't think eigen supports gcc versions that don't provide the noreturn attribute.

Do you know which is the corresponding syntax for MSVC, if any?

>> How do you test for C++11 mode in eigen sources?  Is there a feature
>> test macro, or should I simply use __cplusplus?
> 
> I think that this is a reasonable check.
> 
>    #if __cplusplus >= 201103L
>    // using C++11 or newer
>    #else
>    // using pre-C++11
>    #endif
> 
> At least, it's how GNU system headers do it.  I did a
> 
>    $ grep -r __cplusplus ~/include/Eigen
> 
> but it seems that the C++ version is not checked anywhere.
> 

The last time I've looked, I've seen some move constructor conditionally
declared in C++11 mode, but now I can't find them. How do you support
move semantics in C++11 mode without testing the language version?

> Again, if you are using Autoconf, use the `AX_CXX_COMPILE_STDCXX_11`
> macro from the macro archive:
> 
>    https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html#ax_cxx_compile_stdcxx_11
> 
> It will test what the compiler actually supports, not what it claims to
> support, and will `#define HAVE_CXX11` accordingly.  As a nice extra, it
> will try figure out whether you need to pass the `-std=c++11` or
> whatever flag and add it to the `CXXFLAGS` variable.
> 

Nice, but again, I'm not talking about external configuration tools here...
If you need per-feature availability macros in Eigen to support more C++11
constructs, you need to enable them based on the compiler version, I think.

So, in the end, I'll try to patch Eigen to silence those warnings and I'll
send you patches, only then you'll be able to tell me if they can be included or not.
Ok?

> Moritz

Bye,
Nicola


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/