Package: g++-4.3
Version: 4.3.1-5
Severity: normal

Hi,

I recently run into a bug with the following code (simplified to the
essentials):

#include <cstring>

void foo(const char *path) {
  char *filename = rindex(path, '/');
  *filename = 0;
  ++filename;
}

This clearly violates the constness of path but g++ does not give any
warnings. The reason for this is the declaration in <string.h>:

       char *index(const char *s, int c);
       char *rindex(const char *s, int c);

In C there is no other way to declare them so they work for both char*
and const char* but in C++ there is. These (and probably others)
functions should be declared as

char *index(char *s, int c);
const char *index(const char *s, int c);
char *rindex(char *s, int c);
const char *rindex(const char *s, int c);

MfG
        Goswin

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (400, 'unstable-i386')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.25-kvm-nofb (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages g++-4.3 depends on:
ii  gcc-4.3                   4.3.1-5        The GNU C compiler
ii  gcc-4.3-base              4.3.1-5        The GNU Compiler Collection (base 
ii  libc6                     2.7-12         GNU C Library: Shared libraries
ii  libgmp3c2                 2:4.2.2+dfsg-3 Multiprecision arithmetic library
ii  libmpfr1ldbl              2.3.1.dfsg.1-2 multiple precision floating-point 
ii  libstdc++6-4.3-dev        4.3.1-5        The GNU Standard C++ Library v3 (d

g++-4.3 recommends no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to