https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107615
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
With -W -Wall I get
<source>: In function 'int main()':
<source>:17:39: warning: 'aStr' is used uninitialized [-Wuninitialized]
17 | std::cout << (aClass->*aStr).value() << std::endl;;
| ~~~~~~~~~~~~~~~~~~~~~^~
<source>:14:15: note: 'aStr' was declared here
14 | A::member aStr;
| ^~~~
The code is undefined because of the uninitialized variable.
Once you initialize it, the code works as expected:
A::member aStr = &A::str;