Skip to content

VSCode reports 'converstion from "x" to "y" is invalid in constant-expression evalution', yet code builds fine #2111

@sylveon

Description

@sylveon

Type: LanguageService

Describe the bug

  • OS and Version: Windows 10 build 17686
  • VS Code Version: 1.23.1
  • C/C++ Extension Version: 0.17.4
  • Other extensions you installed (and if the issue persists after disabling them): I have others extensions installed, but after disabling all of them except my theme (Railgun) and this addon, it still persists.
  • Description: VSCode reports an error for code that builds correctly.

To Reproduce
Steps to reproduce the behavior: (The default C++ properties were used)

  1. Clone the following gist: https://gist.github.com/sylveon/b63621297d566d06ab38bd5586eca0ed
  2. Open it in vscode
  3. Open main.cpp
  4. See red squiggles on CalculateHueGradient() call
  5. When hovering, you can read expression must have a constant value -- conversion from "float" to "unsigned short" is invalid in constant-expression evaluation

Expected behavior
No error, like msvc and clang do while building the snippet:

C:\Users\Charles\Git\TranslucentTB>cl test.cpp /EHsc
Microsoft (R) C/C++ Optimizing Compiler Version 19.14.26430 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cpp
Microsoft (R) Incremental Linker Version 14.14.26430.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:test.exe
test.obj
C:\Users\Charles\Git\TranslucentTB>clang-cl --version
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin

C:\Users\Charles\Git\TranslucentTB>clang-cl /EHsc test.cpp
(no output, meaning a successful compilation)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions