Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/7642

Change subject: base: Remove the ability to cprintf stringstreams directly.
......................................................................

base: Remove the ability to cprintf stringstreams directly.

The cprintf functions don't know ahead of time what format characters
are going to be used with what underlying data types, and so any
type must be minimally usable with the default specialization of
format_integer, format_char, format_float and format_string. All of
those functions ultimately print their parameter with out << data
except the one which prints stringstreams. That function accesses the
buffer of the string stream with .str(), and then prints that instead.

That should technically work out ok as long as stringstreams are only
printed using %s, but there's no way to guarantee that ahead of time.
To avoid that problem, and because gem5 doesn't ever actually use the
ability to print stringstreams directly, this change removes that
feature and modifies the corresponding part of the unit test.

If we ever do want to print the contents of a string stream, it won't
be difficult to add a .str() to it.

Change-Id: Id902eaff042b96b374efe0183e5e3be9626e8c88
---
M src/base/cprintf_formats.hh
M src/base/cprintftest.cc
2 files changed, 1 insertion(+), 5 deletions(-)



diff --git a/src/base/cprintf_formats.hh b/src/base/cprintf_formats.hh
index 4c78fdf..f55fb95 100644
--- a/src/base/cprintf_formats.hh
+++ b/src/base/cprintf_formats.hh
@@ -337,10 +337,6 @@
 format_string(std::ostream &out, const T &data, Format &fmt)
 { _format_string(out, data, fmt); }

-inline void
-format_string(std::ostream &out, const std::stringstream &data, Format &fmt)
-{ _format_string(out, data.str(), fmt); }
-
 } // namespace cp

 #endif // __CPRINTF_FORMATS_HH__
diff --git a/src/base/cprintftest.cc b/src/base/cprintftest.cc
index 86694ed..3a1b97e 100644
--- a/src/base/cprintftest.cc
+++ b/src/base/cprintftest.cc
@@ -166,7 +166,7 @@

     std::stringstream foo2;
     foo2 << "stringstream test";
-    ccprintf(ss, "%s\n", foo2);
+    ccprintf(ss, "%s\n", foo2.str());
     EXPECT_EQ(ss.str(), "stringstream test\n");
     ss.str("");


--
To view, visit https://gem5-review.googlesource.com/7642
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id902eaff042b96b374efe0183e5e3be9626e8c88
Gerrit-Change-Number: 7642
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabebl...@google.com>
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to