volatile deprecations in c++20
Jon Turney
jon.turney@dronecode.org.uk
Sun Sep 27 19:30:02 GMT 2026
The remaining warnings with gcc 16 (caused by the change to -std=c++20
by default) relate to the deprecation of the 'volatile' qualifier, which
fall into two groups:
> CXX dcrt0.o
> ../../../../src/winsup/cygwin/dcrt0.cc: In function ‘void dll_crt0_1(void*)’:
> ../../../../src/winsup/cygwin/dcrt0.cc:805:11: error: ‘++’ expression of ‘volatile’-qualified type is deprecated [-Werror=volatile]
> 805 | _my_tls.incyg++;
> ../../../../src/winsup/cygwin/dcrt0.cc:981:15: error: ‘--’ expression of ‘volatile’-qualified type is deprecated [-Werror=volatile]
> 981 | _my_tls.incyg--; /* Not in Cygwin anymore */
> ../../../../src/winsup/cygwin/dcrt0.cc:1006:15: error: ‘--’ expression of ‘volatile’-qualified type is deprecated [-Werror=volatile]
> 1006 | _my_tls.incyg--; /* Not in Cygwin anymore */
> CXX exceptions.o
> ../../../../src/winsup/cygwin/exceptions.cc: In static member function ‘static int exception::handle(EXCEPTION_RECORD*, void*, CONTEXT*, PDISPATCHER_CONTEXT)’:
> ../../../../src/winsup/cygwin/exceptions.cc:841:6: error: ‘++’ expression of ‘volatile’-qualified type is deprecated [-Werror=volatile]
> 841 | me.incyg++;
> | ~~~^~~~~
> ../../../../src/winsup/cygwin/exceptions.cc:856:6: error: ‘--’ expression of ‘volatile’-qualified type is deprecated [-Werror=volatile]
> 856 | me.incyg--;
> | ~~~^~~~~
> CXX signal.o> ../../../../src/winsup/cygwin/signal.cc: In
function ‘void abort()’:
> ../../../../src/winsup/cygwin/signal.cc:407:11: error: ‘++’ expression of ‘volatile’-qualified type is deprecated [-Werror=volatile]
> 407 | _my_tls.incyg++;
I wonder if this is just wrong?
Since the state of incyg is inspected in other threads to determine how
to deliver a signal, marking these as 'volatile' might have been enough
on single-processor systems, but perhaps we need a memory barrier here
(as we already do in the assembly code which manipulates incyg), maybe
by using InterlockedIncrement/Decrement()?
> CXX fork.o
> ../../../../src/winsup/cygwin/fork.cc:47:40: error: ‘volatile’-qualified parameter is deprecated [-Werror=volatile]
> 47 | int parent (volatile char * volatile here);
> | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
> ../../../../src/winsup/cygwin/fork.cc:48:39: error: ‘volatile’-qualified parameter is deprecated [-Werror=volatile]
> 48 | int child (volatile char * volatile here);
> | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
> ../../../../src/winsup/cygwin/fork.cc:135:39: error: ‘volatile’-qualified parameter is deprecated [-Werror=volatile]
> 135 | frok::child (volatile char * volatile here)
> | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
> ../../../../src/winsup/cygwin/fork.cc:208:40: error: ‘volatile’-qualified parameter is deprecated [-Werror=volatile]
> 208 | frok::parent (volatile char * volatile stack_here)
> | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
I can't see what these are doing at all (the parameter is unused in
child(), and has the qualifier stripped off in the two places it's used
in parent()), and the change which added them (in 2007) isn't very
informative.
More information about the Cygwin-developers
mailing list