[Bug c++/52869] [DR 1207] "this" not being allowed in noexcept clauses

neha.gnu.gcc at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Sep 4 12:52:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52869

Neha Gowda <neha.gnu.gcc at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |neha.gnu.gcc at gmail dot com

--- Comment #7 from Neha Gowda <neha.gnu.gcc at gmail dot com> ---
cat test.cpp

==========================================================================
#define _NOEXCEPT_OP(x) noexcept(x)

template<class _Ty> inline
        bool _Swap_adl(_Ty& _Left, _Ty& _Right)
        {       
        return (true);
        }

template<class _Ty1,
        class _Ty2>
        struct pair
        {       
        typedef pair<_Ty1, _Ty2> _Myt;
        typedef _Ty1 first_type;
        typedef _Ty2 second_type;

        void swap(_Myt& _Right)
                _NOEXCEPT_OP(_NOEXCEPT_OP(_Swap_adl(this->first, _Right.first))
                        && _NOEXCEPT_OP(_Swap_adl(this->second,
_Right.second)))

                {       
                if (this != &_Right)
                        {       // different, worth swapping
                        _Swap_adl(first, _Right.first);
                        _Swap_adl(second, _Right.second);
                        }
                }
        _Ty1 first;     
        _Ty2 second;    
        };
==========================================================================
g++ test.cpp -c

test.cpp:18:39: error: invalid use of ‘this’ at top level
test.cpp:19:30: error: invalid use of ‘this’ at top level

Same issue with the current upstream sources as well.
Please let me know if there is any patch or workaround to fix the issue.

Else please let me know how to fix this issue in GCC.

Thanks


More information about the Gcc-bugs mailing list