Opened 3 years ago
Closed 9 months ago
#269 closed defect (fixed)
Wrong type for generics' implicit _sizeof params on 32-bit
| Reported by: | mlbrooks | Owned by: | |
|---|---|---|---|
| Priority: | major | Component: | cfa-cc |
| Version: | 1.0 | Keywords: | |
| Cc: |
Description (last modified by )
Current form of the issue, remaining after partial fix in 58eb9250e:
forall( T * )
void mary( const T & ) {
printf( "%zu\n", sizeof(T) ); // used to fail, because sizeof(-) always had type long unsigned int
for ( i; sizeof(T) ) {
if (i > 0) printf(" ");
printf( "%zu", i); // still failing, because i is always getting type long unsigned int, even when sizeof(-) is getting type size_t
}
printf("\n");
}
int main() {
float x = 3.14;
mary(x);
return 0;
}
Compiling as:
cfa -Wall -Werror -m32 test.cfa
Actual: compilation error: format ‘%zu’ expects argument of type ‘size_t’, but argument 2 has type ‘long unsigned int’ at comment "still failing"
Expected: Run with output
4 0 1 2 3
Original form of the issue, fixed by 58eb9250e:
forall(T)
void fred( T x ) {
printf( "%zu\n", sizeof(T) );
printf( "%zu\n", sizeof(x) );
}
int main() {
char c = 'x';
fred(c);
}
Compiling as
cfa -Wall -Werror x.cfa
Expected, actual on plg2: runs and prints 1 twice.
Actual on ruby: compilation error (twice): format ‘%zu’ expects argument of type ‘size_t’, but argument 2 has type ‘long unsigned int’
(Found by Peter, whittled by Mike.)
Note:
See TracTickets
for help on using tickets.
Revise, given partial fix