Re: Pass by reference problem

2009-02-18 Thread Andrew Pinski
On Mon, Feb 16, 2009 at 7:29 PM, e211 wrote: > > //The following code works and there is no way it should. Seems like a bug > someone put in on purpose > > #include > using namespace std; > > void swap(int *x, int *y) > { >int temp; >temp = *x; >*x = *y; >*y = tem

[Bug c++/39211] Function pass by reference problem, accepts parameters (int, int) to an (int*, int*) function.

2009-02-16 Thread eakrohn at cs dot uiowa dot edu
--- Comment #2 from eakrohn at cs dot uiowa dot edu 2009-02-17 04:00 --- Problem fixed, didn't realize there was a built in swap that was getting called. My mistake. -- eakrohn at cs dot uiowa dot edu changed: What|Removed |Added

[Bug c++/39211] Function pass by reference problem, accepts parameters (int, int) to an (int*, int*) function.

2009-02-16 Thread eakrohn at cs dot uiowa dot edu
--- Comment #1 from eakrohn at cs dot uiowa dot edu 2009-02-17 03:53 --- My concern is this function swap(int *x, int *y){ ... } with this function call int x = 5, y = 7; swap(x,y); compiles and works just fine. But this function swap(int *x){ ... } with this function call int x

[Bug c++/39211] New: Function pass by reference problem, accepts parameters (int, int) to an (int*, int*) function.

2009-02-16 Thread eakrohn at cs dot uiowa dot edu
temp = *x; *x = *y; *y = temp; } int main() { int x = 10; int y = 20; std::cout << x << " " << y << endl; swap(x,y); //this compiles, runs and swaps... it shouldn't std::cout << x << "

Pass by reference problem

2009-02-16 Thread e211
; cout << x << " " << y << endl; swap(x,y); //how does this work, there is no way this should compile and run and actually work cout << x << " " << y << endl; } -- View this message in context: http://www.nab