mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-25 03:55:32 +08:00
libstdc++: Support printing volatile pointers (P1147R1)
To avoid needing to export a new symbol from the library (for now) the new member function uses __attribute__((always_inline)). libstdc++-v3/ChangeLog: * include/std/ostream (operator<<(const volatile void*)): Add new overload, as per P1147R1. * testsuite/27_io/basic_ostream/inserters_other/char/volatile_ptr.cc: New test.
This commit is contained in:
parent
9e136807c5
commit
96955a82f0
@ -251,6 +251,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
{ return *this << "nullptr"; }
|
||||
#endif
|
||||
|
||||
#if __cplusplus > 202002L
|
||||
__attribute__((__always_inline__))
|
||||
__ostream_type&
|
||||
operator<<(const volatile void* __p)
|
||||
{ return _M_insert(const_cast<const void*>(__p)); }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Extracting from another streambuf.
|
||||
* @param __sb A pointer to a streambuf
|
||||
|
@ -0,0 +1,11 @@
|
||||
// { dg-options "-std=gnu++23 -fno-inline" }
|
||||
// { dg-do link { target c++23 } }
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
int i = 0;
|
||||
volatile void* p = &i;
|
||||
std::cout << p << std::endl;
|
||||
}
|
Loading…
Reference in New Issue
Block a user