[Bug c++/42023] New: Different exists with and without standard output.

2009-11-12 Thread chenclf at gmail dot com
Here is my code compiled with "g++ -Wall shell_sort.cpp"
The problem is that the result is different without the standard output in the
shell "shell_sort" function.
Would you please explain why this happens in my program?

#include 
using namespace std;

void shell_sort(int *x, int m)
{
int h;
while (h > 0){
for (int i = 0; i < m; i++){
int temp = x[i], j = i;
while ((j >= h) && (x[j-h] > temp)){
x[j] = x[j - h];
j -= h;
}
x[j] = temp;
}
//  cout << endl;
if ((h / 2) != 0){
h /= 2;
}else if (h == 1){
h = 0;
}else{
h = 1;
}
}
}
int main()
{
int *x = new int[10];
for (int i = 0; i < 10; i++){
x[i] = 30 - 3*i;
}
std::cout << "Original:" << std::endl;
for (int i = 0; i < 10; i++){
std::cout << x[i] << "\t";
}
std::cout << std::endl;
cout << "Output:" 

[Bug c++/42023] Different exists with and without standard output.

2009-11-12 Thread chenclf at gmail dot com


--- Comment #1 from chenclf at gmail dot com  2009-11-13 04:09 ---
Created an attachment (id=19008)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19008&action=view)
the error occured without he the standard output line in the "shell_sort"
function.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42023