[MOAB-dev] r4250 - MOAB/trunk/tools/dagmc
Steve Jackson
sjackson at cae.wisc.edu
Thu Nov 4 12:11:02 CDT 2010
On Nov 4, 2010, at 5:05 , Tim Tautges wrote:
>
>
> On 11/03/2010 11:15 PM, Paul Wilson wrote:
>
>> Theoretically, a standard-compliant replacement could be...
>>
>> CartVect *coords;
>> coords = new CartVect(nverts);
>>
>
> The disadvantage of this usage is you have to remember to delete, which can be a nuisance if you have multiple exit points.
Depending on how the compiler support for the variable-length-array syntax is implemented, calling new/delete may also have notably poorer performance.
>> 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)?
>>
>
> Yep. Ran across this one all the time when I taught that parallel computing course. I wish gnu wouldn't allow that extension.
The syntax you replaced is actually valid c99, but is not formally a part of c++, nor is it likely to appear in any future revision of C++. You can learn more about this than you wanted to know here: http://stackoverflow.com/questions/1887097/variable-length-arrays-in-c . Still, c99 support varies widely across compilers, so even if this was a C and not a C++ context, I'd discourage the variable-length array form as being unportable.
~S
More information about the moab-dev
mailing list