Opened 3 years ago
#265 new defect
Compilation failure passing zero_t through assertions
| Reported by: | mlbrooks | Owned by: | |
|---|---|---|---|
| Priority: | major | Component: | cfa-cc |
| Version: | 1.0 | Keywords: | |
| Cc: |
Description
forall( T | { void helper(T); } )
void wrapper( T x ) {
helper(x);
}
void helper( zero_t ) { printf("zero_t overload\n"); }
void helper( one_t ) { printf("one_t overload\n"); }
void helper( int x ) { printf("int overload, value %d\n", x); }
int main() {
#ifndef SUPPRESS_AT_ISSUE_COMPILE_ERROR
wrapper( 0 );
#endif
wrapper( 1 );
wrapper( (int) 0 );
wrapper( (int) 1 );
}
/*
$cfa x.cfa; ./a.out
ACTUAL: Unintelligible error message from GCC blaming the `wrapper(0)` call
EXPECTED: compiles and runs with output:
zero_t overload
one_t overload
int overload, value 0
int overload, value 1
$cfa x.cfa -DSUPPRESS_AT_ISSUE_COMPILE_ERROR; ./a.out
ACTUAL, EXPECTED: compiles and runs with output:
one_t overload
int overload, value 0
int overload, value 1
Diagnostic:
$cfa x.cfa -CFA -XCFA,-p | grep -F '(void)(0=0)'
ACTUAL: Found
EXPECTED: uh... No.
*/
There is an impact on a programmer using new arrays, when trying to index into a higher-dimensional array using a hardcoded 0 as an index. The repro isn't runnable on the currently-committed source. I'll put the repro here, once the change required to reach the issue is committed.
Note:
See TracTickets
for help on using tickets.