Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 704602 Details for
Bug 917378
sane ref-counting code compiled with -O2 causes SIGSEGV
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
minimal example
gcc-4.1.2-O2-bug.cc (text/plain), 1.39 KB, created by
Kamil Dudka
on 2013-03-03 17:26:45 UTC
(
hide
)
Description:
minimal example
Filename:
MIME Type:
Creator:
Kamil Dudka
Created:
2013-03-03 17:26:45 UTC
Size:
1.39 KB
patch
obsolete
>#if 0 >set -x >g++ $0 -g -O2 -DWORK_AROUND_OPTIMIZATION_BUG && valgrind ./a.out >g++ $0 -g -O2 && valgrind ./a.out >exit $? >#endif > >#include <vector> > >struct RefCnt { > int cnt_; > > RefCnt(): cnt_(1) { } > > bool /* needCloning */ enter() { > ++cnt_; > return false; > } > > bool /* wasLast */ leave() { > return !(--cnt_); > } >}; > >struct RefCntLib { > template <class T> static void enter(T *&ptr) { > if (ptr->refCnt.enter()) > ptr = new T(*ptr); > } > > template <class T> static void leave(T *&ptr) { > if (ptr->refCnt.leave()) > delete ptr; > > ptr = 0; > } >}; > >struct RefItem { > RefCnt refCnt; >}; > >struct RStore { > typedef std::vector<RefItem *> T; > T ents_; > > ~RStore() { > // NOTE: this never iterates because ents_ is always empty > for (T::iterator it = ents_.begin(); it != ents_.end(); ++it) > RefCntLib::leave(*it); > } >}; > >struct RClass { > RClass(): d(new Private) { } > > ~RClass() { > RefCntLib::leave(d); > } > > RClass& operator=(const RClass &); > > struct Private { > RefCnt refCnt; > RStore rStore; > } *d; >}; > >RClass& RClass::operator=(const RClass &ref) >{ > RefCntLib::leave(d); > d = ref.d; >#ifdef WORK_AROUND_OPTIMIZATION_BUG > asm volatile("" ::: "memory"); >#endif > RefCntLib::enter(d); > return *this; >} > >int main() >{ > RClass rc1, rc2; > rc1 = rc2; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 917378
: 704602