| 3 | | forall( dtype T | sized(T) ) { // Removing sized assertion gives CFA error "T declared void" |
| | 3 | {{{ |
| | 4 | forall( otype X ) |
| | 5 | struct wrapper { X item; }; |
| | 6 | |
| | 7 | forall( otype Y |
| | 8 | #ifndef HIDE_ERROR |
| | 9 | | { void unusedHelper( wrapper(Y) ); } |
| | 10 | #endif |
| | 11 | ) |
| | 12 | void f() { |
| | 13 | wrapper(Y) myvar; |
| | 14 | } |
| | 15 | }}} |
| | 16 | |
| | 17 | Actual (plain): GCC error: '_sizeof_S7wrapper_Y1Y_' undeclared |
| | 18 | Actual (-DHIDE_ERROR), Expected (both): Compiler success |
| | 19 | |
| | 20 | Desired for the following case in the memory allocator. Here, the affected function is `balloc`, whose assertion for `$balloc_internal` takes a parameter of type `SS_fill(T)`. In the affected function's body, the object declaration where the failure happens is the `(SS_fill(T)){...}` argument initializer. |
| | 21 | {{{ |
| | 22 | forall( dtype T | sized(T) ) { |
| | 44 | }}} |
| | 45 | Actual: GCC error: '_sizeof_S7SS_fill_Y1T_' undeclared |
| | 46 | Expected: Compiler success |
| | 47 | |
| | 48 | This revision shows the assertion is at fault (but it does not provide a workaround). The assumption of a TT-fitting `$balloc_internal` is changed from an assertion to a declaration. |
| | 49 | {{{ |
| | 50 | forall( dtype T | sized(T) ) { |
| | 51 | union U_fill { char c; T * a; T t; }; |
| | 52 | struct SS_fill { char tag; U_fill(T) fill; }; |
| | 53 | } |
| | 54 | |
| | 55 | static inline forall( dtype T | sized(T) ) { |
| | 56 | T * $balloc_internal( void * Resize, void * Realloc, size_t Align, size_t Dim, SS_fill(T) Fill) { |
| | 57 | return (T*)0p; |
| | 58 | } // $balloc_internal |
| | 59 | |
| | 60 | forall( ttype TT ) { |
| | 61 | T * $balloc_internal( void *, void *, size_t, size_t, SS_fill(T), TT ); |
| | 62 | T * balloc( TT all ) { |
| | 63 | return $balloc_internal( (void*)0p, (void*)0p, 16, 1, (SS_fill(T)){'0', (U_fill(T)){'0'}}, all); |
| | 64 | } // balloc |
| | 65 | } // distribution TT |
| | 66 | } // distribution T |
| | 67 | |
| | 68 | int main() { |
| | 69 | int * abc = balloc(); |
| | 70 | free(abc); |
| | 71 | return 0; |
| | 72 | } |
| | 73 | }}} |
| | 74 | Actual and expected: Compiler success, linker failure to find `$balloc_internal( ..., TT )`. |