ICE when attempting to construct a struct using placement new

Bug #1654404 reported by Clint Bland
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
Fix Released
Medium
Unassigned

Bug Description

- release version
  arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 6.2.1 20161205 (release) [ARM/embedded-6-branch revision 243739]

- whether the toolchain was rebuilt or you are using or binary package
  Using the binary package off launchpad ( https://launchpad.net/gcc-arm-embedded )

- host machine
  Linux leaf 4.8.13-1-ARCH #1 SMP PREEMPT Fri Dec 9 07:24:34 CET 2016 x86_64 GNU/Linux

- preprocessed testcase for us to reproduce
  see attachment: `tu_preprocessed.cc`

- symptom(s)
  internal compiler error when attempting to compile the file

- error/warning message encountered
[green@leaf bug]$ arm-none-eabi-g++ -Os -std=c++14 -c tu_preprocessed.cc
tu.cc: In function 'void fn()':
tu.cc:17:6: internal compiler error: in assign_temp, at function.c:961
 void fn (void)
      ^~
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

===================================================================================

Commentary:

* The issue seems to require specifically using placement new:
    replacing the line using placement new with one simply using new will not trigger the ICE.

* The issue requires both a data member AND a destructor to be present. The presence or absence of a constructor does not change whether the problem presents UNLESS the `create` method is available for inlining.

* The issue does not seem to present when using: g++ (GCC) 6.2.1 20160830

Let me know if you need anything else!

Revision history for this message
Clint Bland (bland-cr) wrote :
description: updated
Revision history for this message
Clint Bland (bland-cr) wrote :

Oh, I forgot one additional thing:

This won't occur with -O0, -O1, -O2, -O3, -O4, -Og but it does occur with -Os.

Changed in gcc-arm-embedded:
status: New → Confirmed
Revision history for this message
Thomas Preud'homme (thomas-preudhomme) wrote :

The bug is due to s_buf not having the same alignment as struct MM. s_buf is 1-byte aligned (because the array element are char) but struct MM is 4-byte aligned because of the int attribute. I agree this should give an error rather than crash. That makes the fix lower priority though.

Best regards.

Changed in gcc-arm-embedded:
importance: Undecided → Medium
Revision history for this message
Thomas Preud'homme (thomas-preudhomme) wrote :

FYI, this has been raised against latest GCC version:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79085

Best regards.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) wrote :

A patch has been posted that solved the ICE I get when compiling Clint's testcase. Once it gets committed and backported to stable branches of GCC we'll include it in our toolchain.

Best regards.

Changed in gcc-arm-embedded:
status: Confirmed → In Progress
Changed in gcc-arm-embedded:
milestone: none → 8-2018-q4-major
status: In Progress → Fix Committed
Joey Ye (jinyun-ye)
Changed in gcc-arm-embedded:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.