Opened 3 months ago

Last modified 3 months ago

#300 new defect

sizeof/typeof as a variable's usage may leave this variable unused

Reported by: mlbrooks Owned by:
Priority: minor Component: cfa-cc
Version: 1.0 Keywords: sizeof unused
Cc:

Description (last modified by mlbrooks)

void fred( const char & p ) {
    printf( "%zu\n", sizeof(p) );
}

forall( T * )
void mary( const T & p ) {
    printf( "%zu\n", sizeof(p) );
}

int main() {
    char x = 'a';
    fred(x);
    mary(x);
    return 0;
}
$cfa -Wall -Wextra -Werror test.cfa

Expected: run, print 1 twice
Actual: compile error: unused parameter (mangled name of) p, twice

Note that in -CFA output, the sizeof(p) expressions are rewritten as

  • sizeof(const char), within fred
  • _sizeof_Y1T, within mary

Also occurs with plain variables, as in tests/sizeof.cfa.

Also occurs with typeof, as in tests/typeof.cfa.

Change History (2)

comment:1 Changed 3 months ago by mlbrooks

Description: modified (diff)
Summary: sizeof as a param's usage may leave this param unusedsizeof as a variable's usage may leave this param unused

Generalize from params to variables.

comment:2 Changed 3 months ago by mlbrooks

Description: modified (diff)
Summary: sizeof as a variable's usage may leave this param unusedsizeof/typeof as a variable's usage may leave this variable unused
Note: See TracTickets for help on using tickets.