🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Walt Bunch Tue, 16 Jan 1996 00:00
Perhaps a non-bug in gcc 2.6.3
#6228
Author: Walt Bunch
Date: Tue, 16 Jan 1996 00:00
39 lines
1083 bytes
Is this a bug in the C++ definition? A method's arg is declared const
in its class declaration, but is allowed to be treated non const in
the method definition. Would at least a warning be helpful here?

#include <stdio.h>

class C
{
  public:
  static void getInt (const int i);
};

void
C::getInt (int i)
{
  i = 17;
}

main ()
{
  int j = 0;
  
  C::getInt (j);

  printf ("j: %d\n", j);   // prints j: 0
}

A similar helpful warning would be for a function or method such as

void
getInt (int i)
{
  i = 17;
}

to get a warning such as "argument passed by value was set and never read".

-- 
Walter.L.Bunch@jpl.nasa.gov
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