Looser throw specifier for 'virtual void Logger::log'


looser throw specifier for 'virtual void Logger::log(nvinfer1::ILogger::Severity, const char*)'


TensorRT 8.0.1

   void log(Severity severity, const char *msg) override {
      LogStreamConsumer(mReportableSeverity, severity)
          << "[TRT] " << std::string(msg) << std::endl;

This function compiles on earlier versions of TRT but not 8.* - how can I adjust it to not be a "looser throw specifier?


Hi @lukee2ni6 ,
Can you please hep us with detailed logs and reproducible model and script.


Hi @lukee2ni6 ,

I had the same error and was able to fix it by adding noexcept so the function looks like:

void Logger::log(Severity severity, const char* msg) noexcept

in the source file and

  virtual void log(Severity severity, const char* msg) noexcept override;

in the header. The noexcept flag is in the declaration of log in ILogger in the NvInferRuntimeCommon.h file. This may have changed from the previous version and specifies that the function cannot thrown an exception, so is a pretty ‘tight’ throw specification. Adding nothrow makes the log function have the same ‘looseness’. My function definition is different from yours but hope this helps!