[Dune] dune-common r5260 - trunk/common

Oliver Sander sander at mi.fu-berlin.de
Mon Oct 20 21:26:50 CEST 2008


Hi Markus!
I spoke with Martin in person about this one.  According to him, the
reason for the specialization really was a compiler warning about the
use of uninitialized memory.  Upon discussion we conjectured that the
real reason for the warning is that FieldVector doesn't implement
operator=.  That way, assignment is a compiler-generated byte-by-byte
copy operation.  Hence, the redundant entry of FieldVector<Foo,0> is copied,
even though it is never used.

Martin and I tried to test and reproduce the warning but we couldn't.
Martin promised to look at it in Freiburg again and remove the 
specialization,
if possible.  There is a FlySpray entry to remind him of this.

--
Oliver

Markus Blatt schrieb:
> Hi
>
> On Tue, Sep 16, 2008 at 11:34:46AM +0200, Robert Kloefkorn wrote:
>   
>> the thing about FieldVector<K,0> is that it should be really an empty 
>> class without any memory consumption. The warning was only a side effect.
>>
>>     
>
> Zero memory consumption? I doubt that one. Even empty classes occupy
> space. Every object consumes at least one byte. You can test this
> rather easily:
>
> #include<dune/common/fvector.hh>
> #include<iostream>
>
> int main(){
>         std::cout<<sizeof(Dune::FieldVector<double,0>)<<" "
>         <<sizeof(Dune::FieldVector<double,0>[4])<<std::endl;
> }
>
>
> The only way to benefit in terms of memory consumption is to
> derive from FieldVector because of empty base class optimization of
> the compiler. Are you really doing that?
>
> Cheers,
>
> Markus
>
> _______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune
>   


-- 
************************************************************************
* Oliver Sander                ** email: sander at mi.fu-berlin.de        *
* Freie Universität Berlin     ** phone: + 49 (30) 838 75217           *
* Institut für Mathematik      ** URL  : page.mi.fu-berlin.de/~sander  *
* Arnimallee 6                 ** -------------------------------------*
* 14195 Berlin, Germany        ** Member of MATHEON (www.matheon.de)   *
************************************************************************





More information about the Dune mailing list