[ https://issues.apache.org/jira/browse/STDCXX-556?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Farid Zaripov updated STDCXX-556: --------------------------------- Environment: MSVC 7.1 with Service Pack 1 Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for 80x86 Copyright (C) Microsoft Corporation 1984-2002. All rights reserved. was:MSVC 7.1 Summary: [MSVC 7.1] Bug in implementation of the empty base optimization (was: Bug in MSVC 7.1 implementation of the empty base optimization) > [MSVC 7.1] Bug in implementation of the empty base optimization > --------------------------------------------------------------- > > Key: STDCXX-556 > URL: https://issues.apache.org/jira/browse/STDCXX-556 > Project: C++ Standard Library > Issue Type: Bug > Components: External > Environment: MSVC 7.1 with Service Pack 1 > Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for 80x86 > Copyright (C) Microsoft Corporation 1984-2002. All rights reserved. > Reporter: Farid Zaripov > > The test below exit with exitcode 1 due to bug in MSVC 7.1 implementation of > the empty base optimization. > ----------------------------- > #include <cstring> > #include <cstdio> > #include <new> > class empty_base { }; > class base > { > public: > base (int val) : __val (val) { } > volatile int __val; > }; > class derived1 : public base, public empty_base > { > public: > derived1 (int val) : base (val), empty_base () { } > }; > class derived2 : public base, public empty_base > { > public: > derived2 (int val) : base (val) { } > }; > template <class T> > int foo (const int val, const char* name) > { > const char fill = '\xdc'; > char buf [sizeof (T) + 1]; > std::memset (buf, fill, sizeof (buf)); > T* t = new (buf) T (val); > int ret = 0; > if (fill != buf [sizeof (T)]) { > ++ret; > std::printf ("buf [sizeof (%s)] expected %d, got %d\n", > name, int (fill), int (buf [sizeof (T)])); > } > if (val != t->__val) { > ++ret; > std::printf ("%s::__val expected %d, got %d\n", > name, val, t->__val); > } > t->~T (); > return ret; > } > int main(int, char**) > { > const int init = 0xcdcdcdcd; > return foo <derived1> (init, "derived1") > + foo <derived2> (init, "derived2"); > } > ----------------------------- > The test output: > ----------------------------- > buf [sizeof (derived1)] expected -36, got 0 > ----------------------------- -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.