I looked into this and the issue is the following:
There is a Cdrom wrapper:
"""
class Cdrom : public pkgCdrom {
public:
bool FindPackages(std::string const &CD,
std::vector<std::string> &List,
std::vector<std::string> &SList,
std::vector<std::string> &SigList,
std::vector<std::string> &TransList,
std::string &InfoDir) {
std::string const startdir = SafeGetCWD();
EXPECT_FALSE(startdir.empty());
bool const result = pkgCdrom::FindPackages(CD, List, SList, SigList, TransList, InfoDir, NULL, 0);
...
}
"""
and a unittest that calls it:
"""
TEST(CDROMTest,FindPackages)
{
Cdrom cd;
std::string InfoDir;
EXPECT_TRUE(cd.FindPackages(path, Packages, Sources, Signatur, Translation, InfoDir));
...
EXPECT_EQ(path + "/.disk/", InfoDir);
}
"""
The actual code for this is apt-pkg/cdrom.cc:
"""
bool pkgCdrom::FindPackages(string CD, vector<string> &List, vector<string> &SList, vector<string> &SigList, vector<string> &TransList,
string &InfoDir, pkgCdromStatus *log,
unsigned int Depth)
{
...
if (DirectoryExists(".disk") == true)
{
if (InfoDir.empty() == true)
InfoDir = CD + ".disk/";
}
...
"""
So I suspect that the optimizer gets confused that InfoDir is a reference or it gets confused because InfoDir is not used in FindPackages anymore and it assumes its dead code.
I tried to create a simplified testcase but failed so far. Whats interessting is that if I add a std::cerr << "debug" line into cdrom.cc lines (or even a "CD = CD"):
"""
if (DirectoryExists(".disk") == true)
{
if (InfoDir.empty() == true) {
std::cerr << "debug" << std::endl;
InfoDir = CD + ".disk/";
}
}
"""
it works (which indicates dead-code elimination to me).
I looked into this and the issue is the following:
There is a Cdrom wrapper: std::string const &CD, :vector< std::string> &List, :vector< std::string> &SList, :vector< std::string> &SigList, :vector< std::string> &TransList, FALSE(startdir. empty() ); :FindPackages( CD, List, SList, SigList, TransList, InfoDir, NULL, 0);
"""
class Cdrom : public pkgCdrom {
public:
bool FindPackages(
std:
std:
std:
std:
std::string &InfoDir) {
std::string const startdir = SafeGetCWD();
EXPECT_
bool const result = pkgCdrom:
...
}
"""
and a unittest that calls it: FindPackages) TRUE(cd. FindPackages( path, Packages, Sources, Signatur, Translation, InfoDir));
"""
TEST(CDROMTest,
{
Cdrom cd;
std::string InfoDir;
EXPECT_
...
EXPECT_EQ(path + "/.disk/", InfoDir);
}
"""
The actual code for this is apt-pkg/cdrom.cc: :FindPackages( string CD,
vector< string> &List,
vector< string> &SList,
vector< string> &SigList,
vector< string> &TransList, s(".disk" ) == true)
"""
bool pkgCdrom:
string &InfoDir, pkgCdromStatus *log,
unsigned int Depth)
{
...
if (DirectoryExist
{
if (InfoDir.empty() == true)
InfoDir = CD + ".disk/";
}
...
"""
So I suspect that the optimizer gets confused that InfoDir is a reference or it gets confused because InfoDir is not used in FindPackages anymore and it assumes its dead code.
I tried to create a simplified testcase but failed so far. Whats interessting is that if I add a std::cerr << "debug" line into cdrom.cc lines (or even a "CD = CD"): s(".disk" ) == true)
"""
if (DirectoryExist
{
if (InfoDir.empty() == true) {
std::cerr << "debug" << std::endl;
InfoDir = CD + ".disk/";
}
}
"""
it works (which indicates dead-code elimination to me).