[Bug c++/37800] New: decrementation problem - different result in similar situations
terrix at wp dot pl
gcc-bugzilla@gcc.gnu.org
Fri Oct 10 16:28:00 GMT 2008
compiled with no any special arguments: g++-4.2 test.cpp
operating system: Linux/Debian 4 (lenny)
problem:
foo(++i, i-1);
i've read non-bugs, but there was no exacly about my situation.
example code:
#include <stdio.h>
void func(int* a, int* b) {
printf("%d %d\n", *a, *b);
}
int main() {
int foo[]={1,2,3};
int *p;
p = foo + 1; // set pointer to point at '2'
func(++p, p); // result: 3 3 (same at msvc and same as gcc)
// OK
p = foo + 1;
func(++p, p - 1); // result at msvc: 3 2., result at gcc: 3 1
// BAD: p variable at second argument isn't yet
// incremented
}
cheers, Mark
--
Summary: decrementation problem - different result in similar
situations
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: terrix at wp dot pl
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37800
More information about the Gcc-bugs
mailing list