This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/37800] New: decrementation problem - different result in similar situations
- From: "terrix at wp dot pl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Oct 2008 16:27:05 -0000
- Subject: [Bug c++/37800] New: decrementation problem - different result in similar situations
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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