[petsc-dev] Hijacked MPI calls...

Barry Smith bsmith at mcs.anl.gov
Thu Sep 15 23:31:36 CDT 2016


> On Sep 15, 2016, at 11:20 PM, Jed Brown <jed at jedbrown.org> wrote:
> 
> Barry Smith <bsmith at mcs.anl.gov> writes:
>>> It's annoying, but it appears to be needed.  It's screwy because enum
>>> ought to be handled no differently than int for this purpose.
>> 
>>   Yeah, we checked and sizeof(enum type) = 4 so there is no need for promotion so I blame it on compiler flakiness.
> 
> Well, the size of enums in general is compiler-dependent.

  Sure, but with THIS compiler it is 4 hence will not be promoted. So the compiler is being obnoxious complaining about code that might have difficulties with other compilers IMHO.

>  (I think our
> use of PetscEnum is technically incorrect unless we have already ensured
> that the actual enums have that size.)  But even if the size varies by
> enum, it's still well-defined and behaves like the compatible int as far
> as varargs should be concerned.

  Interestingly I found somewhere on the web that anything smaller than int is always promoted to int size when passed through ... in the same way float is promoted to double.  So if the enum had size 2 it would be promoted to size 4 when passed through ... and thus the warning from the compiler would be reasonable, IMHO.  Just a random page that discusses the promotion https://www.eskimo.com/~scs/cclass/int/sx11c.html







More information about the petsc-dev mailing list