codeql icon indicating copy to clipboard operation
codeql copied to clipboard

[C++] data flow node not found

Open hello123leo opened this issue 4 weeks ago • 3 comments

g++ version: 4.8.2 codeql version: 2.23.6

main.cpp:

#include "stdint.h"
#include <string>

class Test {
public:
    explicit Test(const uint64_t &id) : id_(id) {}
    
private:
    uint64_t id_;
};

int main(int argc, char* argv[]){
    Test test(123456);
    return 0;
}

create database command:

codeql database create testdb --language=cpp --command='g++ main.cpp -std=c++11' -j 0

query:

from DataFlow::Node n
where n.getLocation().getFile().getBaseName() = "main.cpp"
select n

I can find the data flow node "*constructor init of field id_":

Image

and then i add a string member variable str_ like this(line 9):

#include "stdint.h"
#include <string>

class Test {
public:
    explicit Test(const uint64_t &id) : id_(id) {}
    
private:
    std::string str_{};
    uint64_t id_;
};

int main(int argc, char* argv[]){
    Test test(123456);
    return 0;
}

use the same command to create a new database and the same query to analyze, it seems that i can not find the data flow node "*constructor init of field id_" in the new database.

hello123leo avatar Dec 13 '25 07:12 hello123leo

C:>psexec -i -s cmd.exe

At the new prompt cmd.exe

net use z: \192.168.0.5\temp /user:USER-PC\user 123 /persistent:yes

and add a script (net use z: \192.168.0.5\temp /user:USER-PC\user 123) to run at startup.

rusoprivate883-prog avatar Dec 13 '25 11:12 rusoprivate883-prog

Okay nice 🙂🎉🎉✌️

g++ version: 4.8.2 codeql version: 2.23.6

main.cpp:

#include "stdint.h"
#include <string>

class Test {
public:
    explicit Test(const uint64_t &id) : id_(id) {}
    
private:
    uint64_t id_;
};

int main(int argc, char* argv[]){
    Test test(123456);
    return 0;
}

create database command:

codeql database create testdb --language=cpp --command='g++ main.cpp -std=c++11' -j 0

query:

from DataFlow::Node n
where n.getLocation().getFile().getBaseName() = "main.cpp"
select n

I can find the data flow node "*constructor init of field id_":

Image

and then i add a string member variable str_ like this(line 9):

#include "stdint.h"
#include <string>

class Test {
public:
    explicit Test(const uint64_t &id) : id_(id) {}
    
private:
    std::string str_{};
    uint64_t id_;
};

int main(int argc, char* argv[]){
    Test test(123456);
    return 0;
}

use the same command to create a new database and the same query to analyze, it seems that i can not find the data flow node "*constructor init of field id_" in the new database.

nunubetrappin avatar Dec 13 '25 12:12 nunubetrappin

Hi @hello123leo 👋🏻

I have been able to confirm this behaviour. I'll check with the relevant team to see whether this is a bug or somehow intentional.

mbg avatar Dec 17 '25 10:12 mbg

Hi again @hello123leo,

I have checked with the team and they can confirm that this is a bug. They will look at getting this fixed, but we can't currently provide a timeline for when a fix might be ready. We will post an update here when there is one.

mbg avatar Dec 17 '25 13:12 mbg

Thanks @mbg . Looking forward to a fix.

hello123leo avatar Dec 19 '25 06:12 hello123leo