[petsc-dev] Request for comments: allow C99 internally
Lisandro Dalcin
dalcinl at gmail.com
Wed Mar 11 15:42:20 CDT 2020
On Wed, 11 Mar 2020 at 18:34, Jed Brown <jed at jedbrown.org> wrote:
> My proposal is for PETSc to support the intersection of C99, C11, C++11,
> and any later standards. This (sadly*) excludes VLA.
>
> [*] I don't care about stack allocation, but VLA-pointers are extremely
> useful for multi-dimensional array indexing. I'm sad that C11 made that
> optional.
>
>
Oh, of course. That's extremely handy, I use it a lot in user/demo code
(though not yet in library code) .
My only concerns are stack allocations, it requires developer discipline to
not abuse of it.
> double (*a)[n] = (double (*)[n])p;
>
> a[i][j] = 42;
>
Oh, boy...
PS: BTW, if you use typeof() [*], you can simplify these VLA declarations:
double (*a)[m][n] = (typeof(a)) p;
a[i][j][k] = 42;
[*] Don't remember if it is part of C99 or up
--
Lisandro Dalcin
============
Research Scientist
Extreme Computing Research Center (ECRC)
King Abdullah University of Science and Technology (KAUST)
http://ecrc.kaust.edu.sa/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20200311/0dd07450/attachment.html>
More information about the petsc-dev
mailing list