This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16293] New: __attribute__(([non-]const)): optimization bug?
- From: "pluto at pld-linux dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Jun 2004 09:46:54 -0000
- Subject: [Bug c++/16293] New: __attribute__(([non-]const)): optimization bug?
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
int global_var = 0;
class A {
public:
int foo(const char* const ptr) const
{
#ifdef DO_ERRORS
ptr++;
*ptr = 'x';
tmp = *ptr;
#endif
return 1;
}
int bar_const() __attribute__((const))
{
return 1;
}
int bar_nonconst()
{
global_var++;
return 1;
}
int bar_test()
{
int val = 0;
if (0 && bar_const())
val++;
if (0 && bar_nonconst())
val++;
return val;
}
protected:
char tmp;
};
int main(int, char**)
{
A a;
a.bar_test();
return global_var;
}
# g++ -Wall const.cpp -o const && ./const
# echo $?
0
^^ I've expected global_var == 1.
--
Summary: __attribute__(([non-]const)): optimization bug?
Product: gcc
Version: 3.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pluto at pld-linux dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: pentium3-pld-linux
GCC host triplet: pentium3-pld-linux
GCC target triplet: pentium3-pld-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16293