This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Bug fortran/32732] [Bind C] Character scalars are passed as arrays
- From: Tobias Burnus <burnus at net-b dot de>
- To: Steve Ellcey <sje at cup dot hp dot com>
- Cc: "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, "Christopher D. Rickett" <crickett at lanl dot gov>
- Date: Thu, 26 Jul 2007 11:12:55 +0200
- Subject: Re: [Bug fortran/32732] [Bind C] Character scalars are passed as arrays
- References: <bug-32732-13404@http.gcc.gnu.org/bugzilla/> <20070725225607.14796.qmail@sourceware.org>
Steve Ellcey wrote:
> ------- Comment #4 from sje at cup dot hp dot com 2007-07-25 22:56 -------
> The test case is still not working for me on IA64 HP-UX. I also still see
> gfortran.dg/c_kind_params.f90 failing at all optimization levels.
> c_char_tests.f03 also fail
Well, I think you have to do more debugging then. First, could you run
the two attached programs and compare the "sizeof" sizes; they should
always match, if they don't you you have found one problem.
Otherwise, we need at least the dump of the C and Fortran programs:
- c_kind_params.f90
- c_kinds.c
- c_char_driver.c
- c_char_tests.f03
Tobias
#include <stdio.h>
#include <stdint.h>
#include <complex.h>
#include <stdbool.h>
int main()
{
printf("sizeof(%s) = %ld\n", "bool", sizeof(bool));
printf("sizeof(%s) = %ld\n\n", "char", sizeof(char));
printf("sizeof(%s) = %ld\n", "signed char", sizeof(signed char));
printf("sizeof(%s) = %ld\n", "short", sizeof(short));
printf("sizeof(%s) = %ld\n", "int", sizeof(int));
printf("sizeof(%s) = %ld\n", "long", sizeof(long));
printf("sizeof(%s) = %ld\n", "long long", sizeof(long long));
printf("sizeof(%s) = %ld\n", "size_t", sizeof(size_t));
printf("sizeof(%s) = %ld\n\n", "intptr_t", sizeof(intptr_t));
printf("sizeof(%s) = %ld\n", "float", sizeof(float));
printf("sizeof(%s) = %ld\n", "double", sizeof(double));
printf("sizeof(%s) = %ld\n", "long double", sizeof(long double));
printf("sizeof(%s) = %ld\n", "complex float", sizeof(float complex));
printf("sizeof(%s) = %ld\n", "complex double", sizeof(double complex));
printf("sizeof(%s) = %ld\n\n", "complex long double", sizeof(long double complex));
printf("sizeof(%s) = %ld\n", "int8_t", sizeof(int8_t));
printf("sizeof(%s) = %ld\n", "uint8_t", sizeof(uint8_t));
printf("sizeof(%s) = %ld\n", "int16_t", sizeof(int16_t));
printf("sizeof(%s) = %ld\n", "int16_t", sizeof(uint16_t));
printf("sizeof(%s) = %ld\n", "int32_t", sizeof(int32_t));
printf("sizeof(%s) = %ld\n", "int32_t", sizeof(uint32_t));
printf("sizeof(%s) = %ld\n", "int64_t", sizeof(int64_t));
printf("sizeof(%s) = %ld\n\n", "uint64_t", sizeof(uint64_t));
printf("sizeof(%s) = %ld\n", "int_least8_t", sizeof(int_least8_t));
printf("sizeof(%s) = %ld\n", "uint_least8_t", sizeof(uint_least8_t));
printf("sizeof(%s) = %ld\n", "int_least16_t", sizeof(int_least16_t));
printf("sizeof(%s) = %ld\n", "uint_least16_t", sizeof(uint_least16_t));
printf("sizeof(%s) = %ld\n", "int_least32_t", sizeof(int_least32_t));
printf("sizeof(%s) = %ld\n", "uint_least32_t", sizeof(uint_least32_t));
printf("sizeof(%s) = %ld\n", "int_least64_t", sizeof(int_least64_t));
printf("sizeof(%s) = %ld\n\n", "uint_least64_t", sizeof(uint_least64_t));
return 0;
}
program test
use iso_c_binding
implicit none
call printf("c_bool", sizeof(.true._c_bool), c_bool);
call printf("c_char", sizeof(c_char_'a'), c_char);
print *,''
call printf("c_signed_char", sizeof(0_c_signed_char), c_signed_char);
call printf("short", sizeof(0_c_short), c_short);
call printf("int", sizeof(0_c_int), c_int);
call printf("long", sizeof(0_c_long), c_long);
call printf("long long", sizeof(0_c_long_long), c_long_long);
call printf("size_t", sizeof(0_c_size_t), c_size_t);
call printf("intptr_t", sizeof(0_c_intptr_t), c_intptr_t);
print *,''
call printf("float", sizeof(0.0_c_float), c_float);
call printf("double", sizeof(0.0_c_double), c_double);
call printf("long double", sizeof(0.0_c_long_double), c_long_double);
call printf("complex float", sizeof(cmplx(0.0, c_float_complex)), c_float_complex);
call printf("complex double", sizeof(cmplx(0.0, c_double_complex)), c_double_complex);
call printf("complex long double", sizeof(cmplx(0.0, c_long_double_complex)), c_long_double_complex);
print *, ''
call printf("int8_t", sizeof(0_c_int8_t), c_int8_t);
call printf("int16_t", sizeof(0_c_int16_t), c_int16_t);
call printf("int32_t", sizeof(0_c_int32_t), c_int32_t);
call printf("int64_t", sizeof(0_c_int64_t), c_int64_t);
print *, ''
call printf("int_least8_t", sizeof(0_c_int_least8_t), c_int_least8_t);
call printf("int_least16_t", sizeof(0_c_int_least16_t), c_int_least16_t);
call printf("int_least32_t", sizeof(0_c_int_least32_t), c_int_least32_t);
call printf("int_least64_t", sizeof(0_c_int_least64_t), c_int_least64_t);
contains
subroutine printf(str,size,kind)
character(len=*), intent(in) :: str
integer(8),intent(in) :: size
integer(4),intent(in) :: kind
print '(2a,i0,a,i0)', str,': sizeof = ',size,', kind = ',kind
end subroutine printf
end program test