[dune-functions] More build failures

Carsten Gräser graeser at mi.fu-berlin.de
Fri Sep 18 21:12:00 CEST 2015


Am 18.09.2015 um 15:19 schrieb Christian Engwer:
> On Fri, Sep 18, 2015 at 01:59:58PM +0200, Carsten Gräser wrote:
>> Hi,
>>
>> [...]
>>> Ups, you are right... but the error is still the same
>>>       in-class initializer for static data member is not a constant expression
>>> 	      static const int value = ((const typename std::decay<T>::type*)(nullptr))->size();
>>> 		                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> it's really hard to call a constexpr method if you don't
>> have an object. After digging some more time it seems that
>> the only possible way is to call a constructor inside of
>> decltype. Unfortunately the constructor arguments are not
>> known. Maybe it's OK to restrict this to default-constructible
>> types. I'll have look.
> 
> After discussing with Jö, we agreed that it is necessary to have
> default constructible types. casting from a null ptr and then calling
> a member is undefined behaviour. On the other hand we can safely
> assume that all types we want to pass are either std::array or
> somethingin our scopte. Thus we can always make sure that they are
> default constructible.
> 
> With this assumption the code got a lot simpler and I pushed a fix
> which works with clang and g++.

I also discussed this with Steffen. The main problem is, that
calling a constexpr function is only a constexpr if 'this' is
also a constexpr which is never true for the casted nullptr.
Default constructability is only needed because one has to settle
on one constructor to call and the default constructor is the
only viable solution.

But this will also only solve the problem if the default
constructor is constexpr. Hence your commit only partly
fixes the problem because the HierarchicVectorWrapper
is not used in the posisson example (which is not necessary
but should also work). I just push a follow up fix allowing
to also use FlatMultiIndex in through the wrapper.

Best,
Carsten


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.dune-project.org/pipermail/dune-functions/attachments/20150918/ca087cf8/attachment.sig>


More information about the dune-functions mailing list