Skip to content

Volatile is deprecated in C++20 #1193

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

Closed
Troels51 opened this issue Jun 16, 2020 · 5 comments · Fixed by #1228
Closed

Volatile is deprecated in C++20 #1193

Troels51 opened this issue Jun 16, 2020 · 5 comments · Fixed by #1228
Labels
Language Conformance C++11, style, or language warning topics addressed

Comments

@Troels51
Copy link

Describe the bug
In C++20 a lot of the volatile keyword is being deprecated (P1152R3)
For example deallocate has this problem

To Reproduce
Steps to reproduce the behavior:

  1. Use a new compiler, fx gcc10
  2. Set CMAKE_CXX_STANDARD to 20
  3. Build

Expected behavior
Expected the build to complete

Desktop (please complete the following information):

  • gcc version 10.1.0

Additional context
I ran into this problem because i am using jsoncpp in a project that was setting CXX_STANDARD to 20, and then when we upgraded gcc we were getting compile errors.
For example

jsoncpp-src/include/json/allocator.h:41:36: error: ‘volatile’-qualified parameter is deprecated [-Werror=volatile]
   41 |   void deallocate(volatile pointer p, size_type n) {
      |                   ~~~~~~~~~~~~~~~~~^
@dota17 dota17 assigned dota17 and unassigned dota17 Jul 7, 2020
@dota17 dota17 added the Language Conformance C++11, style, or language warning topics addressed label Jul 7, 2020
@dota17
Copy link
Member

dota17 commented Jul 7, 2020

I think we are far from ready to adapt to the C + + 20 standard. But if you like, you can submit a PR to fix this, and I'd love to review it then.

@cdunn2001
Copy link
Contributor

@dawesc, any opinion? This was originally your code, apparently.

https://en.cppreference.com/w/cpp/language/cv

Some uses of volatile are deprecated: ...

volatile object type as function parameter type or return type;

@ledergec
Copy link

ledergec commented Oct 10, 2020

This seems to be the only reason which prevent to compile with c++20 standard using clang 10.

@ledergec
Copy link

I have create the following PR to fix this:
#1228

@BillyDonahue
Copy link
Contributor

Fixed by #1228

@BillyDonahue BillyDonahue linked a pull request May 14, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language Conformance C++11, style, or language warning topics addressed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants