Question

I've come across Bug 58800 in libstdc++, which causes some of my code to segfault. I have a workaround, but I don't want to use it when a fixed version of libstdc++ is available. What is the right way to check for the version of libstdc++ (via ifdef)? And, ideally, which versions are affected by this bug?

Était-ce utile?

La solution

libstdc++ comes with GCC, so the correct way is to check the GCC version, by testing its __GNUC__, __GNUC_MINOR__ and __GNUC_PATCHLEVEL__ predefined macros.

If you're using libstdc++ with Clang you could test whether __GLIBCXX__ > 20131020UL which is the date the bug was fixed. A release after that date should contain the fix.

Autres conseils

You can use the __GLIBCXX__ macro to check the version information for libstdc++. (There's a list of values in section 7 of the ABI Policy Appendix.)

The bug finishes with a list of versions which have been fixed, but figuring out when the bug was introduced might be trickier. If you were using autoconf, I'd suggest writing a test which crashed if the bug was present.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top