It's the same as the question.
Can the code compiled by C++03
and C++11
produce different results?
Not if it doesn't work on one side. Is there a case where both are executed, but the results are different?
Of course it's possible. It doesn't happen often, but I'll show you an example like that.
#define u8 "abc"
const char* s = u8"def";
s
in is
void f(void *); // #1
void f(...); // #2
template<int N> void g() {
f(0*N);
}
In f(0*N)
inti=(-1) /2;
// C++03
-1
for C++11
and 0
for C++11
template< unsigned len > unsigned int fun(unsigned int x);
typedef unsigned int (*fun_t)(unsigned int);
template< fun_t f > unsigned int fon(unsigned int x);
void total(void) {
// fun<fun<9> >(1) >> 2 //03,11 All available
unsigned int A = fon< fun< 9 > >(1) >>(2);
// In C++03, fun<fun<4> > (2)
// Compilation error on C++11
unsigned int B = fon< fun< 9 >>(1) > >(2);
}
struct foo { void *operator new(size_t x){ throw std::exception(); } }
try {
foo *f = new foo();
catch (std::bad_alloc &) {
// // c++03 code
} } catch (std::exception &) {
// // c++11 code
}
struct A {
~A() {throw "foo";} // C++11 calls std::terminate
};
//...
try {
A a;
} } catch(...) {
// In C++03, catch exception
}
std::list<double> list;
// ...
size_ts = list.size(); // Faster at C++11!
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
610 GDB gets version error when attempting to debug with the Presense SDK (IDE)
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
914 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.