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 1479738 Details for
Bug 1623807
Incorrect variable updates in loop when -O2 is enabled.
[?]
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.
Test code
testLoop.cpp (text/x-csrc), 4.08 KB, created by
Toralf
on 2018-08-30 09:08:15 UTC
(
hide
)
Description:
Test code
Filename:
MIME Type:
Creator:
Toralf
Created:
2018-08-30 09:08:15 UTC
Size:
4.08 KB
patch
obsolete
>/** Test program for issues with variable updates and end condition in loops of > vectors with data types from the Eigen library - see eigen.tuxfamily.org. > The problem can be reproduced without actual Eigen types, and it's not > necessary to access the vector, but a vector of some type must be there, > and it must be based on a specialisation of std::vector<T> such as the one > found in Eigen. */ >#include <iostream> >#include <cmath> >#include <vector> >#include <limits> >#include <cstdlib> > >// Adapted version of allocators from Eigen library, see eigen.tuxfamily.org. >// Original license note: >// This Source Code Form is subject to the terms of the Mozilla >// Public License v. 2.0. If a copy of the MPL was not distributed >// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. >namespace Eigen { >namespace internal { >inline void* aligned_malloc(std::size_t size) >{ > void *original = std::malloc(size+16); > if (original == 0) return 0; > void *aligned = reinterpret_cast<void*>((reinterpret_cast<std::size_t>(original) & ~(std::size_t(15))) + 16); > *(reinterpret_cast<void**>(aligned) - 1) = original; > return aligned; >} > >inline void aligned_free(void *ptr) >{ > if (ptr) std::free(*(reinterpret_cast<void**>(ptr) - 1)); >} >} > > >template<class T> >class aligned_allocator >{ >public: > typedef size_t size_type; > typedef std::ptrdiff_t difference_type; > typedef T* pointer; > typedef const T* const_pointer; > typedef T& reference; > typedef const T& const_reference; > typedef T value_type; > > template<class U> > struct rebind > { > typedef aligned_allocator<U> other; > }; > > pointer address( reference value ) const > { > return &value; > } > > const_pointer address( const_reference value ) const > { > return &value; > } > > aligned_allocator() > { > } > > aligned_allocator( const aligned_allocator& ) > { > } > > template<class U> > aligned_allocator( const aligned_allocator<U>& ) > { > } > > ~aligned_allocator() > { > } > > size_type max_size() const > { > return (std::numeric_limits<size_type>::max)(); > } > > pointer allocate( size_type num, const void* hint = 0 ) > { > return static_cast<pointer>( internal::aligned_malloc( num * sizeof(T) ) ); > } > > void construct( pointer p, const T& value ) > { > ::new( p ) T( value ); > } > > void destroy( pointer p ) > { > p->~T(); > } > > void deallocate( pointer p, size_type ) > { > internal::aligned_free( p ); > } > > bool operator!=(const aligned_allocator<T>& ) const > { return false; } > > bool operator==(const aligned_allocator<T>& ) const > { return true; } >}; >} > >/* Vector specialisation from Eigen - refer to above note */ >namespace std { >template<> class vector<int, std::allocator<int> > : public vector<int, Eigen::aligned_allocator<int> > { > typedef vector<int, Eigen::aligned_allocator<int> > vector_base; >public: > typedef int value_type; > typedef vector_base::allocator_type allocator_type; > typedef vector_base::size_type size_type; > typedef vector_base::iterator iterator; > explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {} > template<typename InputIterator> vector(InputIterator first, InputIterator last, > const allocator_type& a = allocator_type()) > : vector_base(first, last, a) {} vector(const vector& c) : vector_base(c) {} > explicit vector(size_type num, const value_type& val = value_type()) > : vector_base(num, val) {} > vector(iterator start, iterator end) : vector_base(start, end) {} > vector& operator=(const vector& x) > { vector_base::operator=(x); return *this; } }; >} > >int main(int argc, char* argv[]) >{ > double maxCnt=61; > std::vector<int> classValues(21, 2); > double step=classValues.size()/maxCnt; > > double pos=0; > size_t index=0; > > while(index<classValues.size()) { > if(pos<classValues.size()) { > } else { > std::cerr << "SHOULD NOT BE HERE\n"; > } > > std::cerr << " " << pos << " " << index > << " " << static_cast<size_t>(pos) << " " << floor(pos) > << "\n"; > pos+=step; > index=static_cast<size_t>(pos); > } >}
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 1623807
: 1479738