release-3.0.0 broken for C++ builds

Lisandro Dalcin dalcinl at gmail.com
Mon Jul 20 16:09:23 CDT 2009


On Mon, Jul 20, 2009 at 5:49 PM, Barry Smith<bsmith at mcs.anl.gov> wrote:
>
> On Jul 20, 2009, at 3:35 PM, Lisandro Dalcin wrote:
>
>> On Mon, Jul 20, 2009 at 5:01 PM, Barry Smith<bsmith at mcs.anl.gov> wrote:
>>>
>>>  Sorry, fixed.
>>>
>>>  Say, isn't it about time we abolish PetscTruth? Are the C and C++ bool
>>> compatible with each other and compatible with Fortran 90's logical?
>>>
>>
>> C99 "_Bool" and C++ "bool" are likely compatible, at least if the same
>> compiler suite is used... in GCC, both have sizeof() == 1 . I remember
>> this surprised you some time ago, and even you said it was a nonsense
>> (you gave alignment arguments, though I failed to find any issues
>> there)...
>>
>
>   So in C99 and C++ the boolean type has a different name?

In you #include <stdbool.h>, you get 'bool', 'true' and 'false' ...

>That seems really  stupid.

Well, form a backward compatibility POV, it is not so stupid... What
about user code written for C89 having a  'typedef int bool', '#define
true 1'; '#define false 0'

> So we will still need a PetscTruth macro that maps to bool in c++ and _Bool
> in c?

Moreover, if a C compiler does not support the C99 boolean, you will
have to hack it..

>
> Then it is not worth changing.
>

And we would have to investigate all the compatibility issues at the
binary level with the many Fortran's out there.

Finally... You will have to wait until MPI 3.0, in the hope we have
support for portably communicating C99 bool data....

So in short, I think PetscTruth should remain being an enumeration. We
just need to take care when coding, and test building with C++ in a
regular basis. The later would be enough for spotting mistakes... As
time passes, GCC gets more and more pedantic...


>> Regarding Fortran, I'm not so sure about compatibility... we could
>> have two problems:
>>
>> 1) non-matching sizeof() with the C99/C++ type, though in F90 we could
>> use logical(kind=XXX), right?
>> 2) Can we be 100% sure that in Fortran .TRUE./.FALSE. match C99/C++
>> true/false in a bit-by-bit basis? I mean, is .FALSE. a 0 (zero) at the
>> binary level?
>>
>>
>>
>>>  Barry
>>>
>>> On Jul 20, 2009, at 12:51 PM, Lisandro Dalcin wrote:
>>>
>>>> Barry, this time you are the guy to blame ;-) (at least for the push)
>>>>
>>>> All these lines like below in src/mat/impls/aij/mpi/mpiaij.c are
>>>> wrong, you do not have implicit bool -> enum in C++.
>>>>
>>>> MatStashValuesXXX_Private(...., ignorezeroentries && (addv ==
>>>> ADD_VALUES))
>>>>
>>>>
>>>> libfast in: /usr/local/petsc/3.0.0/src/mat/impls/aij/mpi
>>>> mpiaij.c: In function PetscErrorCode MatSetValues_MPIAIJ(_p_Mat*,
>>>> PetscInt, const PetscInt*, PetscInt, const PetscInt*, const
>>>> PetscScalar*, InsertMode):
>>>> mpiaij.c:396: error: cannot convert bool to PetscTruth for argument 6
>>>> to PetscErrorCode MatStashValuesRow_Private(MatStash*, PetscInt,
>>>> PetscInt, const PetscInt*, const PetscScalar*, PetscTruth)
>>>> mpiaij.c:398: error: cannot convert bool to PetscTruth for argument 7
>>>> to PetscErrorCode MatStashValuesCol_Private(MatStash*, PetscInt,
>>>> PetscInt, const PetscInt*, const PetscScalar*, PetscInt, PetscTruth)
>>>> mpiaij.c: In function void matsetvaluesmpiaij_(_p_Mat**, PetscInt*,
>>>> const PetscInt*, PetscInt*, const PetscInt*, const PetscScalar*,
>>>> InsertMode*, PetscErrorCode*):
>>>> mpiaij.c:5242: error: cannot convert bool to PetscTruth for argument 6
>>>> to PetscErrorCode MatStashValuesRow_Private(MatStash*, PetscInt,
>>>> PetscInt, const PetscInt*, const PetscScalar*, PetscTruth)
>>>> mpiaij.c:5244: error: cannot convert bool to PetscTruth for argument 7
>>>> to PetscErrorCode MatStashValuesCol_Private(MatStash*, PetscInt,
>>>> PetscInt, const PetscInt*, const PetscScalar*, PetscInt, PetscTruth)
>>>>
>>>>
>>>> --
>>>> Lisandro Dalcín
>>>> ---------------
>>>> Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
>>>> Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
>>>> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
>>>> PTLC - Güemes 3450, (3000) Santa Fe, Argentina
>>>> Tel/Fax: +54-(0)342-451.1594
>>>
>>>
>>
>>
>>
>> --
>> Lisandro Dalcín
>> ---------------
>> Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
>> Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
>> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
>> PTLC - Güemes 3450, (3000) Santa Fe, Argentina
>> Tel/Fax: +54-(0)342-451.1594
>
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594



More information about the petsc-dev mailing list