aras-p / ClangBuildAnalyzer

Clang build analysis tool using -ftime-trace
The Unlicense
1.01k stars 65 forks source link

Mismatch between printf format string and arguments #20

Closed ilyapopov closed 5 years ago

ilyapopov commented 5 years ago

While compiling on Linux with GCC 9, I get the following warnings:

src/BuildEvents.cpp: In function ‘void DebugPrintEvents(const BuildEvents&, const BuildNames&)’:
src/BuildEvents.cpp:15:26: warning: format ‘%i’ expects argument of type ‘int’, but argument 3 has type ‘BuildEventType’ [-Wformat=]
   15 |         printf("%4zi: t=%i t1=%7llu t2=%7llu par=%4i ch=%4zi det=%s\n", i, event.type, event.ts, event.ts+event.dur, event.parent.idx, event.children.size(), names[event.detailIndex].substr(0,130).c_str());
      |                         ~^                                                 ~~~~~~~~~~
      |                          |                                                       |
      |                          int                                                     BuildEventType
src/BuildEvents.cpp:15:35: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘int64_t’ {aka ‘long int’} [-Wformat=]
   15 |         printf("%4zi: t=%i t1=%7llu t2=%7llu par=%4i ch=%4zi det=%s\n", i, event.type, event.ts, event.ts+event.dur, event.parent.idx, event.children.size(), names[event.detailIndex].substr(0,130).c_str());
      |                               ~~~~^                                                    ~~~~~~~~
      |                                   |                                                          |
      |                                   long long unsigned int                                     int64_t {aka long int}
      |                               %7lu
src/BuildEvents.cpp:15:44: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘long int’ [-Wformat=]
   15 |         printf("%4zi: t=%i t1=%7llu t2=%7llu par=%4i ch=%4zi det=%s\n", i, event.type, event.ts, event.ts+event.dur, event.parent.idx, event.children.size(), names[event.detailIndex].substr(0,130).c_str());
      |                                        ~~~~^                                                     ~~~~~~~~~~~~~~~~~~
      |                                            |                                                             |
      |                                            long long unsigned int                                        long int
      |                                        %7lu
$ g++ --version
g++ (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008
ilyapopov commented 5 years ago

Well, the size of long long int and long int is the same on Linux, so it should not be a big problem. However, silencing the warnings would be nice.