This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/26644] New: const vs. almost-const
- From: "pentek_imre at mailbox dot hu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Mar 2006 14:35:34 -0000
- Subject: [Bug c++/26644] New: const vs. almost-const
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Hello, try to compile this code:
class G
{
public:
G();
~G();
bool test() const;
int *x;
};
G::G()
{
x=new int[7];
x[3]=99;
}
G::~G()
{
delete[] x;
}
bool G::test() const
{
x[3]--;
return true;
}
I used
g++ -W -Wall -ansi -pedantic G.cpp -c -o G.o
and it gives no errors, so *x isn't considered to be const, but IMHO it should
be.
I use this gcc:
Reading specs from /usr/lib/gcc/i586-uhu-linux/3.4.5/specs
Configured with: /var/uhubuild/work/compile/configure --prefix=/usr
--infodir=/usr/share/info --mandir=/usr/share/man --enable-languages=c,c++
--enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib
--host=i586-uhu-linux
Thread model: posix
gcc version 3.4.5
--
Summary: const vs. almost-const
Product: gcc
Version: 3.4.5
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pentek_imre at mailbox dot hu
GCC host triplet: i586-uhu-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26644