Community
cancel
Showing results for 
Search instead for 
Did you mean: 
bernhardmgruber
Beginner
224 Views

Compilation failure with constexpr if

Hi! I did not find a better way to report this issue, so I report it here:

Using icpc (ICC) 2021.1.2 20201208 via oneAPI on Ubuntu 20.10 fails to compile the following program:

#include <fstream>

constexpr auto FALSE = false;

template <typename T>
void f() {
    if constexpr (FALSE)
        std::ofstream{"file"} << "asdf";
}

int main() {
    f<int>();
}
<source>(8): error: expected an expression
          std::ofstream{"file"} << "asdf";
                                ^
          detected during instantiation of "void f<T>() [with T=int]" at line 13

Godbolt: https://godbolt.org/z/7vb1ah6av

The problem does not appear if `f` is not a template, if `FALSE` is `true`, or the ctor of the temporary `ostream` is called using parentheses. I think this is a frontend issue parsing the body of the constexpr if.

I have a more complex case of this happending in my library, so I would be happy if the compiler team could address this. Thank you!

0 Kudos
4 Replies
AbhishekD_Intel
Moderator
178 Views

Hi,

 

Thanks for the complete details and the reproducer.

We are also getting the same error with the ICC Compiler(2021.1.2 20201208), and those errors are very much reproducible. We will look into this issue.

Meanwhile, you can use the ICX Compiler to compile your use-case.

 

 

Warm Regards,

Abhishek

 

Viet_H_Intel
Moderator
169 Views

I've reported this bug to our Front End team.

Thanks,


VidyalathaB_Intel
Moderator
75 Views

Hi,

 

The version against which you reported your issue is no longer targeted for fixes. Please check out the new versions of Intel oneAPI Toolkits for the latest features.

 

Regards,

Vidya.

.

 

 

VidyalathaB_Intel
Moderator
54 Views

Hi,


We are closing this thread for now. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Thanks & Regards,

Vidya.


Reply