Skip to content
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 does not recognize a constexpr variable used in another constexpr definition #4736

Open
hriekehof opened this issue Dec 12, 2019 · 4 comments
Labels
bug Language Service more votes needed Issues that have been postponed until more community members upvote it Visual Studio Inherited from Visual Studio
Milestone

Comments

@hriekehof
Copy link

Type: LanguageService

Describe the bug

  • OS and Version: Windows 10
  • VS Code Version: 1.40.2
  • C/C++ Extension Version: 0.26.2
  • Intellisense Information is provided by: cmake-integration extension

If i use a previously defined constexpr variable in another. IntelliSense give the error message
expression must have a constant value which is case i think. gcc-8-2019-q1 compiles fine.

To Reproduce

  1. Create a constexpr variable
  2. Create a second constexpr variable and use the first one in it
  3. See error

Expected behavior
IntelliSense should not mark this as an error.

Screenshots

Error Message

Code

Additional context

@Colengms
Copy link
Collaborator

Hi @hriekehof . In your example, expf() is not a constexpr. Is that the issue? Or, are you saying that after along1 and ashort1 failed to compile as constexpr, subsequent error messages that refer to them as non-constexpr should not be displayed?

@Colengms
Copy link
Collaborator

I think what's happening here is that although expf is not declared as a constexpr in math.h, gcc is replacing it with a compiler intrinsic (instead of a library call) and that's allowing it to be resolved as constexpr at compile time. This may not be the case for all architectures gcc supports, but would seem to be the case for x86 and x64, so our gcc-x86 and gcc-x64 IntelliSense modes probably should not squiggle it.

I opened the following issue against VS (as we share common code for IntelliSense with VS). https://developercommunity.visualstudio.com/content/problem/854941/intellisense-shows-squiggle-for-use-of-gcc-compile.html

@Colengms Colengms added Language Service Visual Studio Inherited from Visual Studio labels Dec 12, 2019
@Colengms Colengms added this to the Tracking milestone Dec 12, 2019
@hriekehof
Copy link
Author

@Colengms i think you are right. i totally missed that along1, ashort1 also have already squiggle lines.
Just for my interesset since i don't know much about it. At the moment i work on an embedded project. So my compiler is arm-none-arm-gcc. So far the gcc-x86 mode for intellisense works most of the time fine. But i think there are other build in functions specific for arm. Would it then be a good idea to have an intellisense mode for gcc-arm and gcc-arm64 ?

@Colengms
Copy link
Collaborator

Hi @hriekehof . Yes indeed. We are tracking that with #4271

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Language Service more votes needed Issues that have been postponed until more community members upvote it Visual Studio Inherited from Visual Studio
Projects
None yet
Development

No branches or pull requests

3 participants