base: Prevent undefined behavior in not interleaved `AddrRange`s.
[gem5.git] / src / base / output.cc
index 47b8aa7f4de25b5b283b920bf7bef54e55b1ac3a..5703a379caf9fdcfafffedc36ab4c94c253eeeeb 100644 (file)
@@ -84,9 +84,11 @@ OutputFile<StreamType>::OutputFile(const OutputDirectory &dir,
     _mode(mode), _recreateable(recreateable),
     _fstream(static_cast<stream_type_t *>(_stream))
 {
-    _fstream->open(dir.resolve(_name).c_str(), _mode);
+    std::string resolved_path = dir.resolve(_name);
 
-    assert(_fstream->is_open());
+    _fstream->open(resolved_path.c_str(), _mode);
+
+    panic_if(!_fstream->is_open(), "Failed to open \"%s\"\n", resolved_path);
 }
 
 template<class StreamType>