Menu

#155 Logging functions are not declared with printf-like "format" function attribute

Feature Request
closed-fixed
None
5
2026-03-17
2021-04-12
No

gcc has a "format" attribute to declare that a function or method accepts a printf-like format string and variable arguments. This allows the compiler to check the type of arguments. For example a warning is emitted if attempting to pass an std::string without .c_str() call.

log4cpp does not use this attribute in places where it could. As a result, the code compile without warnings and problems are found only at runtime.

Discussion

  • Alexander Perepelkin

    • status: open --> open-accepted
    • assigned_to: Alexander Perepelkin
     
  • Alexander Perepelkin

    • status: open-accepted --> closed-fixed
     
  • Alexander Perepelkin

    @pulkomandy, thanks for highlighting that.

    The issue is addressed with 007e1a39add173f6fc97e61a4cc91cfd4081d542 and will be included into next release.

    __attribute__((format(printf, fmt, arg))) is utilized for GCC/Clang

     

    Last edit: Alexander Perepelkin 2026-03-17

Log in to post a comment.

MongoDB Logo MongoDB