🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by "Douglas C. Schmidt" Tue, 01 Nov 1988 01:26
More permissive g++ behavior
#1515
Author: "Douglas C. Schmidt"
Date: Tue, 01 Nov 1988 01:26
33 lines
1189 bytes
Hi,

   Here is another case of const perversion that g++ should probably
complain about: 

----------------------------------------
#include <stream.h>

int * Foo ( const int *p ) {
   return ( p );  // attempt to circumvent the const qualifier
}   

main (int, char *argv[]) {
   int  i = atoi ( argv [ 1 ] );
   const int *p = &i;
   *( Foo ( p ) ) = 10;
   cout << *p << "\n";
}
----------------------------------------

cfront 1.2.1 prints out:

----------------------------------------
CC  test.C:
"test.C", line 4: error: bad return value type for Foo(): const int * ( int * expected)
1 error
----------------------------------------


Doug
----------
schmidt@bonnie.ics.uci.edu (ARPA) | Quis costodiet ipsos custodes?
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads