[gnu.g++.bug] g++ too permissive with const * parameters

schmidt%blanche.ics.uci.edu@ORION.CF.UCI.EDU ("Douglas C. Schmidt") (11/01/88)

Hi,

   The following program demonstrates an attempt to circumvent the const
specifier:

----------------------------------------
void foo ( const int *f ) {
   int *foo = f;
   *foo = 100;  // defeat const!
}

main () {
   int foobar;
   int *bar = &foobar;
   foo ( bar );
}
----------------------------------------

g++ doesn't complain about this, whereas CC retorts:

----------------------------------------
CC  test.C:
"test.C", line 6: error: bad initializer type const int * for foo ( int * expected)
1 error
----------------------------------------

This seems like a reasonable approach, no?


Doug
------------------------------
schmidt@bonnie.ics.uci.edu (ARPA) |   Per me si va nella cita dolente.
                                  |   Per me si va nell' etterno dolore.
                                  |   Per me si va tra la perduta gente.
                                  |   Lasciate ogni speranza voi ch' entrate.