dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #10392
Re: [HG DOLFIN] Use const_cast to get UFCCell to compile.
On Sun, Oct 26, 2008 at 12:03:27AM +0200, Anders Logg wrote:
> On Sat, Oct 25, 2008 at 11:17:15PM +0200, DOLFIN wrote:
> > One or more new changesets pushed to the primary dolfin repository.
> > A short summary of the last three changesets is included below.
> >
> > changeset: 4993:01188514d401addaa869e7c99acc87dce6889f3b
> > tag: tip
> > user: "Garth N. Wells <gnw20@xxxxxxxxx>"
> > date: Sat Oct 25 22:17:05 2008 +0100
> > files: dolfin/fem/UFCCell.h
> > description:
> > Use const_cast to get UFCCell to compile.
> >
> > Should ufc::cell::entity_indices and ufc::cell::coordinates be
> >
> > unsigned int const** and
> >
> > double const**
> >
> > ?
>
> Yes, it looks like we've made a mistake in UFC.h. I found the
> following uses of "const" and "*" in UFC.h:
Sorry, this is obviously completely wrong! I took a closer look at
what the position of "const" means. It should indeed by
const double*
which means that the objects pointed to (the values in the array) are
const.
In the case with ufc::cell::coordinates and ufc::cell::entity_indices,
it would be difficult to insert any const since that would prevent
users from copying values into the ufc::cell data structures. We might
also need to do that (rather than set the pointer to point to the data
in the DOLFIN mesh).
--
Anders
> 1. const double* coordinates
>
> This should really be
>
> double* const coordinates
>
> This means that the function promises not to change the values in the
> coordinates array, which is what we want. The way we do it now is that
> we promise not to change the pointer, which has no meaning since the
> pointer is passed by value and changing that copied pointer inside the
> function does not modify the pointer passed to the function.
>
> 2. const double* dof_values
>
> Same here.
>
> 3. const double * const * w
>
> This should really be
>
> double * const * const w
>
> meaning that we don't change the arrays pointed to and not the values
> in those arrays.
>
> 4. const char* signature() const = 0;
>
> Why don't we use std::string here?
>
> Can we change this in UFC? It's needed for const-correctness in DOLFIN
> (and other codes that may use UFC).
>
> Martin?
>
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev
Attachment:
signature.asc
Description: Digital signature
References