[Bug libcc1/105695] GCC 10.3.1 (20220519) build failure with GCC 12

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon May 23 08:01:52 GMT 2022


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-05-23
           Keywords|                            |build
     Ever confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Indeed.

#include <utility>

void foo (void *a, void *b)
{
  std::swap (a, b);
}

> ~/install/gcc-12/usr/local/bin/g++ t.C -S -std=gnu++03
t.C: In function 'void foo(void*, void*)':
t.C:5:8: error: 'swap' is not a member of 'std'
    5 |   std::swap (a, b);
      |        ^~~~

works with GCC 11.  <algorithm> is required pre C++11 for std::swap.  We
have

#ifdef __cplusplus
#if defined (INCLUDE_ALGORITHM) || !defined (HAVE_SWAP_IN_UTILITY)
# include <algorithm>
#endif

but config.h was likely generated with the default C++ standard and not with
explicit -std=gnu++98.


More information about the Gcc-bugs mailing list