Include <algorithm> in .pb_text.cc generated files
authorDerek Murray <mrry@google.com>
Thu, 17 May 2018 14:10:01 +0000 (07:10 -0700)
committerGitHub <noreply@github.com>
Thu, 17 May 2018 14:10:01 +0000 (07:10 -0700)
The generated code depends on this header for `std::stable_sort()`. Until now we've been lucky that this header is included indirectly on the platforms for which we build. Fixes #19323.

tensorflow/tools/proto_text/gen_proto_text_functions_lib.cc

index 62e29b5..aa56cc6 100644 (file)
@@ -803,6 +803,9 @@ void Generator::Generate(const FileDescriptor& fd) {
   // Add header to cc file.
   SetOutput(&cc_);
   Print("// GENERATED FILE - DO NOT MODIFY");
+  Print();
+  Print("#include <algorithm>");  // for `std::stable_sort()`
+  Print();
   headers = {GetProtoTextHeaderName(fd, true /* impl */)};
   AddHeadersToCurrentSection(headers);
   Print();