- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
I am currently learning Fortran for Project Euler (ignore the quality of the code you'll about to see) and as such I have chosen Intel Fortran. I attached the code, as well as the CMakeLists.txt I used.
When I use ifort and gfortran, I get the right answer: 142913828922
But when I use ifx, the answer is... 0. It is displaying the `sum` variable, which was initialized with 2, so it's even more of a mystery.
I am considering this a bug in the compiler, and my theory is that the compiler optimized way too much of the loop, and I don't know why ifx in particular doesn't work, while ifort and gfortran do. I haven't (to my knowledge) enabled any optimizations and the same exact code works on other compilers.
System and compiler:
$ uname -a
Linux delphi 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
$ ifx -V
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2024.1.0 Build 20240308
Copyright (C) 1985-2024 Intel Corporation. All rights reserved
$ which ifx
/opt/intel/oneapi/compiler/2024.1/bin/ifx
If you need other info, let me know.
Regards,
Stefan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The program is missing a "mod" call:
is_prime = .not. btest(prime((x-1)/64 + 1), x / 2)
=>
is_prime = .not. btest(prime((x-1)/64 + 1), mod(x / 2,32))
The btest call must have a bit-index that is less than the integer bit-size. Otherwise the value is undefined. After adding the "mod" call the program can work correctly with ifx.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just ran that in IFX on windows and it gives 142913828922 with /Od and /O1 but with /O2 it gives zero. Optimiser bug.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A bug report has been opened. We will fix it in the future product.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The program is missing a "mod" call:
is_prime = .not. btest(prime((x-1)/64 + 1), x / 2)
=>
is_prime = .not. btest(prime((x-1)/64 + 1), mod(x / 2,32))
The btest call must have a bit-index that is less than the integer bit-size. Otherwise the value is undefined. After adding the "mod" call the program can work correctly with ifx.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page