-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intellisense incorrectly identifies pow() as a non-constexpr, which causes constexpr functions containing pow() to incorrectly show an error #13122
Comments
@twfry I get the same error when using the clang++ or cl.exe compilers, so it looks like it may be relying on a g++ extension that our IntelliSense compiler doesn't currently emulate. Your repro code didn't compile as provided, so my modified repro code is #include <array>
#include <cmath>
constexpr std::array<float, 256> gen_lut() {
std::array<float, 256> lut = {};
for (int i = 0; i < 256; ++i) {
lut[i] = std::pow(2.0f, static_cast<float>(i));
}
return lut;
}
constexpr auto linear_lut = gen_lut(); |
This was previously reported in #4736 but closed because EDG doesn't support replacing the parsed header code with the compiler intrinsics. cppreference.com says this won't officially be constexpr until C++26. |
@sean-mcmanus here is a short working example. VSCode shows an error in line 22 over genereate_lut(). However g++ compiles it cleanly with all warnings on.
Compiles with no warnings or errors using:
executes successfully
|
@bobbrow I understand cppreference requires support by c++26, however g++ supports this today. Since VSCode supports Remote Explore and g++ through that, that seems to imply VSCode should support g++ existing capabilities. For us it isn't a blocker to development, but it is a significant annoyance to the point we just turn Intellisense off, which itself is an issue. |
@twfry Yes, our IntelliSense parser is supposed to emulate the gcc behavior. I've filed an internal bug 2333165. A reduced repro for the issue is int main()
{
constexpr double c = __builtin_pow(0.0, 0.0);
} |
Thank you for filing the bug. Yes that is a much better reduced repro. |
Environment
Bug Summary and Steps to Reproduce
Bug Summary:
We have a constexpr function that contains the math function pow(). This compiles fine on g++ however Intellisense shows an error, the error reported is "cannot call non-constexpr function "__builtin_powf" (declared implicitly)". However the code compiles cleanly and works as expected.
Steps to reproduce:
Simplified example
The error is reported under the gen_lut(); call in the last line.
Expected behavior:
Intellisense should not report an error. This is valid C++ that compiles on g++ 11.4
Configuration and Logs
Other Extensions
No response
Additional context
This bug prevents our projects from reporting no error, which impacts development since it is difficult to notice during development when there is an actual bug and we don't notice later till the compilation fails.
The text was updated successfully, but these errors were encountered: