Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DREDD Ignores False #if Directives, Potentially Resulting In Invalid Code During Compilation #201

Closed
JonathanFoo0523 opened this issue Nov 22, 2023 · 1 comment

Comments

@JonathanFoo0523
Copy link
Collaborator

Steps To Reproduce:

int main() {
    int foo;
    foo = 1
    #if BAR
        | 19
    #endif
        ;
}

After running DREDD on the above file(named baz.c), compiling with clang baz.c -DBAR results in syntax error.

@afd
Copy link
Member

afd commented Nov 22, 2023

This is actually expected behaviour. At mutation time, Dredd accepts a compilation database, specifying which compiler options - such as -D and -I options - should be used to process the source file. It processes the source file in the context of those options, and thus mutates for one particular set of preprocessor symbols.

You cannot later compile the mutated code with different preprocessor symbols.

This is a good post on compilation databases:

https://eli.thegreenplace.net/2014/05/21/compilation-databases-for-clang-based-tools

@afd afd closed this as completed Nov 22, 2023
afd pushed a commit that referenced this issue Sep 28, 2024
Describe common reasons and possible workarounds for Dredd's mutated
source file to fail to compile or cause a build failure, including the
lack of a compilation database and multiple conflicting compilation
contexts in the database.

Related issue: #347.
Related issue: #201.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants