Hi,
Segmentation fault sometimes occurs in a program when icpc is used.
The version of icpc I am using is 17.0.2 20170213, and the version of g++ is 5.2.0.
It does not happen when g++ is used.
This issue was originally found in BOUT++ code. (https://github.com/boutproject/BOUT-dev)
Please have a look at the attached reproducer.
It was written based on BOUT++ code.
If g++ is used:
$ ./a.out
0
0
1
1
1
2
2
2
But if icpc is used:
$ ./a.out.intel
0
0
...
Segmentation fault (core dumped)
Please note that sometimes the segfault does not occur, but always the output is corrupted.(0 0 0....)
The problem does not happen even if icpc is used when
1) a copy constructor is defined (a.out.intel.copy)
2) reference variables are not used (a.out.intel.noref)
Though this issue had been fixed in BOUT++ code by doing 2) (https://github.com/boutproject/BOUT-dev/pull/468), but I still suspect this is a bug of intel compiler because the problem does not happen with g++.
Is this a bug of icpc?
Best regards,
Daichi