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

On text operator, reported unexpected error #13036

Open
pointertobios opened this issue Dec 9, 2024 · 9 comments
Open

On text operator, reported unexpected error #13036

pointertobios opened this issue Dec 9, 2024 · 9 comments
Labels
Milestone

Comments

@pointertobios
Copy link

pointertobios commented Dec 9, 2024

Environment

  • OS and Version: archlinux
  • VS Code Version: 1.95.3
  • C/C++ Extension Version: 1.22.11

Bug Summary and Steps to Reproduce

Bug Summary:

inline constexpr unsigned long long operator"" u64(unsigned long long n){return n;}

auto x = 0xfffu64 + 1u64;

reported "Extra text after expected end of number" on 0xfffu64 and 1u64 and consider them as int.

But it can be compiled by g++ and clang++. And there is no limit about number character on the text operator in C++ standard.

Configuration and Logs

none

Other Extensions

No response

Additional context

No response

@sean-mcmanus
Copy link
Contributor

@pointertobios I'm seeing compiler errors with g++/clang++ -- what version are you using and what args like -std=c++20 are you using?

@sean-mcmanus sean-mcmanus self-assigned this Dec 9, 2024
@sean-mcmanus sean-mcmanus added Language Service more info needed The issue report is not actionable in its current state parser labels Dec 9, 2024
@pointertobios
Copy link
Author

pointertobios commented Dec 9, 2024

@pointertobios I'm seeing compiler errors with g++/clang++ -- what version are you using and what args like -std=c++20 are you using?

@sean-mcmanus yes c++20

@pointertobios
Copy link
Author

@pointertobios I'm seeing compiler errors with g++/clang++ -- what version are you using and what args like -std=c++20 are you using?

@sean-mcmanus sorry I just type wrong code.the argument is also unsigned long long in my actually used code.I corrected the example now.

@pointertobios
Copy link
Author

Screenshot_20241210_042741.jpg

@pointertobios
Copy link
Author

Screenshot_20241210_042950.jpg

@pointertobios
Copy link
Author

In clang++ add a _ before can be compiled.
But c/c++ extension reported the same error

@Colengms
Copy link
Contributor

Colengms commented Dec 9, 2024

Hi @pointertobios . If I add "_", like so:

inline constexpr unsigned long long operator"" _u64(unsigned long long n){return n;}

auto x = 0xfff_u64 + 1_u64;

int main() {
	return 0;
}

... For me, that both allows the code to compile with clang++ and clears up the IntelliSense squiggle. If you're seeing something different, could you provide a complete example, in the form of a zip file or GitHub repo, that we might use to reproduce exactly what you're seeing?

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Dec 10, 2024

@Colengms clang++ gives an error, but g++ (and cl.exe) only gives a warning. IntelliSense is normally not supposed to give errors in warning cases.

But writing code that only compiles with g++ and not other compilers (or potential future g++ versions) isn't recommended.

@sean-mcmanus sean-mcmanus added bug Visual Studio Inherited from Visual Studio and removed more info needed The issue report is not actionable in its current state labels Dec 10, 2024
@sean-mcmanus sean-mcmanus added this to the Tracking milestone Dec 10, 2024
@sean-mcmanus
Copy link
Contributor

@sean-mcmanus sean-mcmanus removed their assignment Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

3 participants