Problem with the pgc++ compiler

I am having a problem with the pgc++ compiler.I will try to illustrate the problem with a simple program:

(Sorry for the square bracket used instead of the regular ones)
+++++++++++++++++++++++++++++++++++++++++++++++++++
#include
#include
using namespace std;
int main()
[
for (int j = 0; j < 5; j++) [
int power = pow(3, j);
cout << “j: " << j <<”, power: " << power << ", pow(3, j): " << pow(3, j) << endl;
]
] // end main() //
+++++++++++++++++++++++++++++++++++++++++++++++++++
While the output from g++ is (as expected):
j: 0, power: 1, pow(3, j): 1
j: 1, power: 3, pow(3, j): 3
j: 2, power: 9, pow(3, j): 9
j: 3, power: 27, pow(3, j): 27
j: 4, power: 81, pow(3, j):

the output produced by the pgi compiler is:

j: 0, power: 1, pow(3, j): 1
j: 1, power: 2, pow(3, j): 3
j: 2, power: 9, pow(3, j): 9
j: 3, power: 27, pow(3, j): 27
j: 4, power: 81, pow(3, j): 81

Notice the second value, for j = 1, power:2 while pow(3,j) is 3. The pow() function produce the correct answer (3), but the value assigned to the power variable is incorrect (2). That only happen for j=1.

I am using:
pgc++ 17.10-0 64-bit target on x86-64 Linux -tp haswell
PGI Compilers and Tools
Copyright © 2017, NVIDIA CORPORATION. All rights reserved.

Can someone reproduce this problem?

Thanks.

Hello,

This one is weird! It seems to only fail on haswell cpus.
Compile on a machine with an older cpu, and it will work correctly
on that machine. But run the same executable on a haswell, and the error occurs.

This is logged as TPR 24937.

dave

Thanks!

Issue should be resolved in 18.7.