This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/68023] New: 4.8.4 generates good code where 5.2 generates bad code


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68023

            Bug ID: 68023
           Summary: 4.8.4 generates good code where 5.2 generates bad code
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barto at cambridgesemantics dot com
  Target Milestone: ---

Created attachment 36543
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36543&action=edit
Configuration for GCC 4.8.4

The following code:
template <class T>
 inline
 SPORef<T>::SPORef
  /// Constructor: increment pointed to T's reference count.
  ( T* p                ///< Pointer to the T to be managed
  )
  : rep_(p)
{
  badcode();
  if (rep_)
    rep_->incReferences();
}

template <class T>
 inline
 SPORef<T>::~SPORef
  /// Destructor: decrement pointed to T's reference count, possibly
  /// triggering its destruction.
  ()
{
  badcode();
  if (rep_) {
    rep_->decReferences();
    rep_ = 0;
  }
}

when compiled optimized with GCC 4.8.4 runs properly when compiled -O3.
Changing the compiler (and associated tool chain) from 4.8 to 5.2 causes the
code generated from these functions to cause the system to crash. Changing the
optimization around these 2 methods only by using:

#pragma GCC push_options
#pragma GCC optimize("O0")
<failing code>
#pragma GCC pop_options

and the gcc 5.2 compiler will successfully compile the code.

Attached are the .ii files for 4.8 and 5.2 as well as the configuration files
for 4.8 and 5.2.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]