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

Change subject: base: Change how the integer formatting template function is set up.
......................................................................

base: Change how the integer formatting template function is set up.

Previously it was defined so that it had specializations for char based
versions so that they wouldn't be printed as chars and would be
printed as integer values. Otherwise, the generic specialization would
pass all types to the "_format_integer" template function. The problem
is that the calling function had a data dependent code path which could
pass arbitrary types to the format_integer function, and that had a
call to out << data in it. If the target type didn't have the <<
operator defined, then the build would fail. This seems reasonable,
since the format string is technically not required to be a build time
constant, and the function has to know what to do if somebody tries to
print a string stream as an integer for some reason, even if that's
just to complain and explode.

As a somewhat experimental fix, this change uncomments some other
specializations for all (I think) other basic integer types, and makes
the unspecialized version print an error like the char and float format
functions. I don't know for sure why those were commented out, and this
may introduce some sort of error.

This seems to passify clang and passes the relevant unit test and
ARM's gem5.opt builds, so it can't be totally broken this way.
Hopefully this fix is correct.

Change-Id: I55f7ccefbe6025044fc5adbc059e759507b1c3bc
---
M src/base/cprintf_formats.hh
1 file changed, 1 insertion(+), 3 deletions(-)



diff --git a/src/base/cprintf_formats.hh b/src/base/cprintf_formats.hh
index 253fe59..9e74e04 100644
--- a/src/base/cprintf_formats.hh
+++ b/src/base/cprintf_formats.hh
@@ -302,7 +302,7 @@
 template <typename T>
 inline void
 format_integer(std::ostream &out, const T &data, Format &fmt)
-{ _format_integer(out, data, fmt); }
+{ out << "<bad arg type for integer format>"; }
 inline void
 format_integer(std::ostream &out, char data, Format &fmt)
 { _format_integer(out, (int)data, fmt); }
@@ -312,7 +312,6 @@
 inline void
 format_integer(std::ostream &out, signed char data, Format &fmt)
 { _format_integer(out, (int)data, fmt); }
-#if 0
 inline void
 format_integer(std::ostream &out, short data, Format &fmt)
 { _format_integer(out, data, fmt); }
@@ -337,7 +336,6 @@
 inline void
 format_integer(std::ostream &out, unsigned long long data, Format &fmt)
 { _format_integer(out, data, fmt); }
-#endif

 //
 // floating point formats

--
To view, visit https://gem5-review.googlesource.com/7583
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: I55f7ccefbe6025044fc5adbc059e759507b1c3bc
Gerrit-Change-Number: 7583
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