🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6228

Perhaps a non-bug in gcc 2.6.3

#6228
From: 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
Technical Details
Message-ID: <9601162205.AA18983@tazboy.JPL.NASA.GOV>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,175dff47bfbdb898,start
X-Google-Attributes: gid113d02,public
From: bunch@tazboy.jpl.nasa.gov (Walt Bunch)
Subject: Perhaps a non-bug in gcc 2.6.3
Date: 1996/01/16
Message-ID: <9601162205.AA18983@tazboy.JPL.NASA.GOV>
X-Deja-AN: 135543481
distribution: gnu
sender: daemon@cis.ohio-state.edu
organization: GNUs Not Usenet
newsgroups: gnu.gcc.bug