From 27cdcf1ff3ab25fd10be0b1377b97ab31de04a64 Mon Sep 17 00:00:00 2001 From: xbauch Date: Tue, 25 Feb 2020 16:32:33 +0000 Subject: [PATCH] Fix over-writing library prologue when linking the cprover library. The default mode for this constructor of stringstream is to over-write the string used in construction, which presumably was not the intention here. Note: until now there wasn't anything too interesting in the prologue except for the string-abstraction define, which was ignored. But we might want more defines in the future. --- src/ansi-c/cprover_library.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ansi-c/cprover_library.cpp b/src/ansi-c/cprover_library.cpp index 285f9b7e108..34bf78beb3f 100644 --- a/src/ansi-c/cprover_library.cpp +++ b/src/ansi-c/cprover_library.cpp @@ -45,7 +45,9 @@ std::string get_cprover_library_text( const struct cprover_library_entryt cprover_library[], const std::string &prologue) { - std::ostringstream library_text(prologue); + // the default mode is ios_base::out which means subsequent write to the + // stream will overwrite the original content + std::ostringstream library_text(prologue, std::ios_base::ate); std::size_t count=0;