mc-imperial / dredd

Framework for evaluating C/C++ compiler testing tools
Apache License 2.0
11 stars 3 forks source link

Dredd includes system headers before headers that must be before system headers #219

Closed JamesLee-Jones closed 1 month ago

JamesLee-Jones commented 5 months ago

This can be demonstrated by creating test.h:

#if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) &&  defined(__CONFIG_H__)
#  error test.h must be #included before system headers
#endif

and test.c:

#include "test.h"

int main() {
  int x = 1 + 2;
}

This compiles with clang test.c, but after running dredd test.c the modified program no longer compiles and gives the error

./test.h:2:4: error: test.h must be #included before system headers

In more complicated projects, such as binutils, this can cause Dredd to fail to instrument any of the source files.