same code, same library version, same compiler, different output
up vote
4
down vote
favorite
File h.cpp
#include "yaml-cpp/yaml.h"
#include <iostream>
int main() {
YAML::Node node = YAML::Load("[1, 2, 3]");
std::cout << node << "n";
std::cout << node.Type() << "n";
std::cout << node.IsSequence() << "n";
}
compiled and executed with
g++ -lyaml-cpp h.cpp && ./a.out
yields
[1, 2, 3]
3
1
on my desktop, but
[1, 2, 3]
1
0
on my laptop. The last line of laptop output is wrong: For sure, the given YAML string is a sequence.
Same results when g++ is replaced by clang++. Both machines run the same Debian 4.18.10-2, both are x86_64, both run Linux 4.18.0-2-amd64, both have same versions of g++ and clang++. Both have the same yaml-cpp library versions, freshly reinstalled:
$ locate libyaml-cpp.
/usr/lib/x86_64-linux-gnu/libyaml-cpp.a
/usr/lib/x86_64-linux-gnu/libyaml-cpp.so
/usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5
/usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5.2
$ dpkg -S /usr/lib/x86_64-linux-gnu/libyaml-cpp.a
libyaml-cpp-dev: /usr/lib/x86_64-linux-gnu/libyaml-cpp.a
$ dpkg -S /usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5.2
libyaml-cpp0.5v5:amd64: /usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5.2
$ apt-cache show libyaml-cpp-dev
Package: libyaml-cpp-dev
Source: yaml-cpp
Version: 0.5.2-4
$ apt-cache show libyaml-cpp0.5v5
Package: libyaml-cpp0.5v5
Source: yaml-cpp
Version: 0.5.2-4
Output from ldd is identical except for the hex addresses in parentheses:
$ ldd a.out
linux-vdso.so.1 (0x00007ffd0d5f0000)
libyaml-cpp.so.0.5 => /usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5 (0x00007f1e9fcd8000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1e9fb55000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1e9f9c1000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1e9f9a7000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1e9f7ea000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1e9ff79000)
What possible explanations remain in such a situation?
c++ yaml-cpp
|
show 2 more comments
up vote
4
down vote
favorite
File h.cpp
#include "yaml-cpp/yaml.h"
#include <iostream>
int main() {
YAML::Node node = YAML::Load("[1, 2, 3]");
std::cout << node << "n";
std::cout << node.Type() << "n";
std::cout << node.IsSequence() << "n";
}
compiled and executed with
g++ -lyaml-cpp h.cpp && ./a.out
yields
[1, 2, 3]
3
1
on my desktop, but
[1, 2, 3]
1
0
on my laptop. The last line of laptop output is wrong: For sure, the given YAML string is a sequence.
Same results when g++ is replaced by clang++. Both machines run the same Debian 4.18.10-2, both are x86_64, both run Linux 4.18.0-2-amd64, both have same versions of g++ and clang++. Both have the same yaml-cpp library versions, freshly reinstalled:
$ locate libyaml-cpp.
/usr/lib/x86_64-linux-gnu/libyaml-cpp.a
/usr/lib/x86_64-linux-gnu/libyaml-cpp.so
/usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5
/usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5.2
$ dpkg -S /usr/lib/x86_64-linux-gnu/libyaml-cpp.a
libyaml-cpp-dev: /usr/lib/x86_64-linux-gnu/libyaml-cpp.a
$ dpkg -S /usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5.2
libyaml-cpp0.5v5:amd64: /usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5.2
$ apt-cache show libyaml-cpp-dev
Package: libyaml-cpp-dev
Source: yaml-cpp
Version: 0.5.2-4
$ apt-cache show libyaml-cpp0.5v5
Package: libyaml-cpp0.5v5
Source: yaml-cpp
Version: 0.5.2-4
Output from ldd is identical except for the hex addresses in parentheses:
$ ldd a.out
linux-vdso.so.1 (0x00007ffd0d5f0000)
libyaml-cpp.so.0.5 => /usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5 (0x00007f1e9fcd8000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1e9fb55000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1e9f9c1000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1e9f9a7000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1e9f7ea000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1e9ff79000)
What possible explanations remain in such a situation?
c++ yaml-cpp
2
You may not be running thea.out
you think you are running in one or both environments, especially if thePATH
differs between the two. Avoid this risk by specifically executing./a.out
instead of relying on a path lookup to find the executable.
– John Bollinger
Nov 9 at 22:46
Valid point, but not the explanation here. I'll edit the question to rule out this possibility.
– Joachim W
Nov 9 at 23:05
1
The most reasonable explanation is the YAML library is having undefined behavior. You can try running it under sanitizers or manually check the code.
– Dani
Nov 9 at 23:09
It might be helpful to see what this outputs:std::cout << node.Type() << " : " << YAML::NodeType::Sequence << "n";
– David Schwartz
Nov 10 at 0:04
node.Type()
output also differs,3
vs1
– Joachim W
Nov 10 at 6:16
|
show 2 more comments
up vote
4
down vote
favorite
up vote
4
down vote
favorite
File h.cpp
#include "yaml-cpp/yaml.h"
#include <iostream>
int main() {
YAML::Node node = YAML::Load("[1, 2, 3]");
std::cout << node << "n";
std::cout << node.Type() << "n";
std::cout << node.IsSequence() << "n";
}
compiled and executed with
g++ -lyaml-cpp h.cpp && ./a.out
yields
[1, 2, 3]
3
1
on my desktop, but
[1, 2, 3]
1
0
on my laptop. The last line of laptop output is wrong: For sure, the given YAML string is a sequence.
Same results when g++ is replaced by clang++. Both machines run the same Debian 4.18.10-2, both are x86_64, both run Linux 4.18.0-2-amd64, both have same versions of g++ and clang++. Both have the same yaml-cpp library versions, freshly reinstalled:
$ locate libyaml-cpp.
/usr/lib/x86_64-linux-gnu/libyaml-cpp.a
/usr/lib/x86_64-linux-gnu/libyaml-cpp.so
/usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5
/usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5.2
$ dpkg -S /usr/lib/x86_64-linux-gnu/libyaml-cpp.a
libyaml-cpp-dev: /usr/lib/x86_64-linux-gnu/libyaml-cpp.a
$ dpkg -S /usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5.2
libyaml-cpp0.5v5:amd64: /usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5.2
$ apt-cache show libyaml-cpp-dev
Package: libyaml-cpp-dev
Source: yaml-cpp
Version: 0.5.2-4
$ apt-cache show libyaml-cpp0.5v5
Package: libyaml-cpp0.5v5
Source: yaml-cpp
Version: 0.5.2-4
Output from ldd is identical except for the hex addresses in parentheses:
$ ldd a.out
linux-vdso.so.1 (0x00007ffd0d5f0000)
libyaml-cpp.so.0.5 => /usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5 (0x00007f1e9fcd8000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1e9fb55000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1e9f9c1000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1e9f9a7000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1e9f7ea000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1e9ff79000)
What possible explanations remain in such a situation?
c++ yaml-cpp
File h.cpp
#include "yaml-cpp/yaml.h"
#include <iostream>
int main() {
YAML::Node node = YAML::Load("[1, 2, 3]");
std::cout << node << "n";
std::cout << node.Type() << "n";
std::cout << node.IsSequence() << "n";
}
compiled and executed with
g++ -lyaml-cpp h.cpp && ./a.out
yields
[1, 2, 3]
3
1
on my desktop, but
[1, 2, 3]
1
0
on my laptop. The last line of laptop output is wrong: For sure, the given YAML string is a sequence.
Same results when g++ is replaced by clang++. Both machines run the same Debian 4.18.10-2, both are x86_64, both run Linux 4.18.0-2-amd64, both have same versions of g++ and clang++. Both have the same yaml-cpp library versions, freshly reinstalled:
$ locate libyaml-cpp.
/usr/lib/x86_64-linux-gnu/libyaml-cpp.a
/usr/lib/x86_64-linux-gnu/libyaml-cpp.so
/usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5
/usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5.2
$ dpkg -S /usr/lib/x86_64-linux-gnu/libyaml-cpp.a
libyaml-cpp-dev: /usr/lib/x86_64-linux-gnu/libyaml-cpp.a
$ dpkg -S /usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5.2
libyaml-cpp0.5v5:amd64: /usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5.2
$ apt-cache show libyaml-cpp-dev
Package: libyaml-cpp-dev
Source: yaml-cpp
Version: 0.5.2-4
$ apt-cache show libyaml-cpp0.5v5
Package: libyaml-cpp0.5v5
Source: yaml-cpp
Version: 0.5.2-4
Output from ldd is identical except for the hex addresses in parentheses:
$ ldd a.out
linux-vdso.so.1 (0x00007ffd0d5f0000)
libyaml-cpp.so.0.5 => /usr/lib/x86_64-linux-gnu/libyaml-cpp.so.0.5 (0x00007f1e9fcd8000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1e9fb55000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1e9f9c1000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1e9f9a7000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1e9f7ea000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1e9ff79000)
What possible explanations remain in such a situation?
c++ yaml-cpp
c++ yaml-cpp
edited Nov 10 at 21:28
asked Nov 9 at 22:41
Joachim W
2,35831329
2,35831329
2
You may not be running thea.out
you think you are running in one or both environments, especially if thePATH
differs between the two. Avoid this risk by specifically executing./a.out
instead of relying on a path lookup to find the executable.
– John Bollinger
Nov 9 at 22:46
Valid point, but not the explanation here. I'll edit the question to rule out this possibility.
– Joachim W
Nov 9 at 23:05
1
The most reasonable explanation is the YAML library is having undefined behavior. You can try running it under sanitizers or manually check the code.
– Dani
Nov 9 at 23:09
It might be helpful to see what this outputs:std::cout << node.Type() << " : " << YAML::NodeType::Sequence << "n";
– David Schwartz
Nov 10 at 0:04
node.Type()
output also differs,3
vs1
– Joachim W
Nov 10 at 6:16
|
show 2 more comments
2
You may not be running thea.out
you think you are running in one or both environments, especially if thePATH
differs between the two. Avoid this risk by specifically executing./a.out
instead of relying on a path lookup to find the executable.
– John Bollinger
Nov 9 at 22:46
Valid point, but not the explanation here. I'll edit the question to rule out this possibility.
– Joachim W
Nov 9 at 23:05
1
The most reasonable explanation is the YAML library is having undefined behavior. You can try running it under sanitizers or manually check the code.
– Dani
Nov 9 at 23:09
It might be helpful to see what this outputs:std::cout << node.Type() << " : " << YAML::NodeType::Sequence << "n";
– David Schwartz
Nov 10 at 0:04
node.Type()
output also differs,3
vs1
– Joachim W
Nov 10 at 6:16
2
2
You may not be running the
a.out
you think you are running in one or both environments, especially if the PATH
differs between the two. Avoid this risk by specifically executing ./a.out
instead of relying on a path lookup to find the executable.– John Bollinger
Nov 9 at 22:46
You may not be running the
a.out
you think you are running in one or both environments, especially if the PATH
differs between the two. Avoid this risk by specifically executing ./a.out
instead of relying on a path lookup to find the executable.– John Bollinger
Nov 9 at 22:46
Valid point, but not the explanation here. I'll edit the question to rule out this possibility.
– Joachim W
Nov 9 at 23:05
Valid point, but not the explanation here. I'll edit the question to rule out this possibility.
– Joachim W
Nov 9 at 23:05
1
1
The most reasonable explanation is the YAML library is having undefined behavior. You can try running it under sanitizers or manually check the code.
– Dani
Nov 9 at 23:09
The most reasonable explanation is the YAML library is having undefined behavior. You can try running it under sanitizers or manually check the code.
– Dani
Nov 9 at 23:09
It might be helpful to see what this outputs:
std::cout << node.Type() << " : " << YAML::NodeType::Sequence << "n";
– David Schwartz
Nov 10 at 0:04
It might be helpful to see what this outputs:
std::cout << node.Type() << " : " << YAML::NodeType::Sequence << "n";
– David Schwartz
Nov 10 at 0:04
node.Type()
output also differs, 3
vs 1
– Joachim W
Nov 10 at 6:16
node.Type()
output also differs, 3
vs 1
– Joachim W
Nov 10 at 6:16
|
show 2 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53234192%2fsame-code-same-library-version-same-compiler-different-output%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
You may not be running the
a.out
you think you are running in one or both environments, especially if thePATH
differs between the two. Avoid this risk by specifically executing./a.out
instead of relying on a path lookup to find the executable.– John Bollinger
Nov 9 at 22:46
Valid point, but not the explanation here. I'll edit the question to rule out this possibility.
– Joachim W
Nov 9 at 23:05
1
The most reasonable explanation is the YAML library is having undefined behavior. You can try running it under sanitizers or manually check the code.
– Dani
Nov 9 at 23:09
It might be helpful to see what this outputs:
std::cout << node.Type() << " : " << YAML::NodeType::Sequence << "n";
– David Schwartz
Nov 10 at 0:04
node.Type()
output also differs,3
vs1
– Joachim W
Nov 10 at 6:16