Another case of assignment from a value-initialized temporary, which in this case ought to be placement new.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit ccd4031ebdabf02fe0d54bb43a68c0fa72ec2708 Author: Jason Merrill <ja...@redhat.com> Date: Thu May 17 17:16:28 2018 -0400 * line-map.c (linemap_init): Use placement new. * system.h: #include <new>. diff --git a/libcpp/line-map.c b/libcpp/line-map.c index a84084c99f0..b2ebfeb16d4 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -348,7 +348,7 @@ linemap_init (struct line_maps *set, /* PR33916, needed to fix PR82939. */ memset (set, 0, sizeof (struct line_maps)); #else - *set = line_maps (); + new (set) line_maps(); #endif set->highest_location = RESERVED_LOCATION_COUNT - 1; set->highest_line = RESERVED_LOCATION_COUNT - 1; diff --git a/libcpp/system.h b/libcpp/system.h index 719435df949..76420e16cfb 100644 --- a/libcpp/system.h +++ b/libcpp/system.h @@ -438,6 +438,10 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; /* Some compilers do not allow the use of unsigned char in bitfields. */ #define BOOL_BITFIELD unsigned int +#ifdef __cplusplus +#include <new> +#endif + /* Poison identifiers we do not want to use. */ #if (GCC_VERSION >= 3000) #undef calloc