[MOAB-dev] r4250 - MOAB/trunk/tools/dagmc

Paul Wilson wilsonp at engr.wisc.edu
Wed Nov 3 23:15:53 CDT 2010


Hello,

To be clear - while the former may not be valid, the replacement is 
actually semantically different.

The first declares a pointer to a C-style array of nvert objects of size 
CartVect.  The second uses an STL vector for the same.

Theoretically, a standard-compliant replacement could be...

    CartVect *coords;
    coords = new CartVect(nverts);

I ask because the valid set of operations on variable 'coords' changes 
with the change you made and it seems possible that other places would 
need to be modified accordingly. Or is that new set of operations a 
strict superset of the original operations?

And while I am asking tutorial questions... is the original a problem 
because the notation is only correct (in a standards compliant way) for 
only constant sized arrays (compile time)?

Paul


On 11/03/2010 08:19 PM, tautges at mcs.anl.gov wrote:
> Author: tautges
> Date: 2010-11-03 20:19:00 -0500 (Wed, 03 Nov 2010)
> New Revision: 4250
>
> Modified:
>     MOAB/trunk/tools/dagmc/quads_to_tris.cpp
> Log:
> Replacing non-standard line:
>
>     CartVect coords[nverts]
>
> with
>    std::vector<CartVect>  coords(nverts)
>
> This mistake is fairly common, and gcc allows it when it really shouldn't.
>
>
>
> Modified: MOAB/trunk/tools/dagmc/quads_to_tris.cpp
> ===================================================================
> --- MOAB/trunk/tools/dagmc/quads_to_tris.cpp	2010-11-04 01:02:37 UTC (rev 4249)
> +++ MOAB/trunk/tools/dagmc/quads_to_tris.cpp	2010-11-04 01:19:00 UTC (rev 4250)
> @@ -32,7 +32,7 @@
>     assert( MB_SUCCESS == result);
>
>     // find length of diagonals
> -  CartVect coords[n_verts];
> +  std::vector<CartVect>  coords(n_verts);
>     result = MBI->get_coords( quad_conn, n_verts, coords[0].array() );
>     if(MB_SUCCESS != result) return result;
>     CartVect diagA = coords[0] - coords[2];
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

-- 
-- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ --
Paul Wilson ~ UW-Madison ~ 608-263-0807 ~ cal: http://bit.ly/pphw-cal
Associate Professor, Engineering Physics. ~ http://cnerg.engr.wisc.edu
Chair, Energy Analysis&  Policy Program ~ http://nelson.wisc.edu/eap
Note: I will be on sabbatical for the 2010-2011 academic year.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3369 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.mcs.anl.gov/pipermail/moab-dev/attachments/20101103/aa5d65b8/attachment.bin>


More information about the moab-dev mailing list