PR28417, std::string no longer allows accepting nullptr_t
authorAlan Modra <amodra@gmail.com>
Tue, 19 Oct 2021 23:39:57 +0000 (10:09 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 20 Oct 2021 21:24:27 +0000 (07:54 +1030)
PR 28417
* incremental.cc (Sized_relobj_incr::do_section_name): Avoid
std:string undefined behaviour.
* options.h (Search_directory::Search_directory): Likewise.

gold/incremental.cc
gold/options.h

index 52941985e6f1d13b977a58af25b9823bee24af9c..327a1527a29dbbb3d46dae9f3f625cba1a629b7b 100644 (file)
@@ -2286,7 +2286,7 @@ Sized_relobj_incr<size, big_endian>::do_section_name(unsigned int shndx) const
   const Output_sections& out_sections(this->output_sections());
   const Output_section* os = out_sections[shndx];
   if (os == NULL)
-    return NULL;
+    return std::string();
   return os->name();
 }
 
index 757ebf18fecfa45dd16affc29c816c6975e07b60..47299a37834c8f3196492b676eb45c374e3d7dc7 100644 (file)
@@ -611,7 +611,7 @@ class Search_directory
   // We need a default constructor because we put this in a
   // std::vector.
   Search_directory()
-    : name_(NULL), put_in_sysroot_(false), is_in_sysroot_(false)
+    : name_(), put_in_sysroot_(false), is_in_sysroot_(false)
   { }
 
   // This is the usual constructor.