This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/1833: inlining sometimes causes incorrect behavior
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/1833: inlining sometimes causes incorrect behavior
- From: peteb at sitera dot com
- Date: 1 Feb 2001 19:22:39 -0000
- Reply-To: peteb at sitera dot com
>Number: 1833
>Category: c++
>Synopsis: inlining sometimes causes incorrect behavior
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Feb 01 11:26:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Peter Bartlett
>Release: gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
>Description:
The attached program calls two versions of a function,
one inlined and the other not. The inlined function does
not behave correctly. The type casting of a (char *)
argument to (const char *) as an argument to another funtion
that takes (const char *&) does not properly modify the
argument in the calling function in the inlined version.
>How-To-Repeat:
#include <iostream>
void frob2 (const char*& s)
{
s += 3;
}
inline void frob_fail (char *s)
{
frob2((const char *)s);
cerr << "should be 34567: " << s << endl;
}
void frob_pass (char *s)
{
frob2((const char *)s);
cerr << "should be 34567: " << s << endl;
}
int main (unsigned argc, const char *const argv[])
{
char *x = "01234567";
frob_fail(x);
char *y = "01234567";
frob_pass(y);
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: