Bug 88410 - [8 Regression] internal compiler error: output_operand: invalid expression as operand
Summary: [8 Regression] internal compiler error: output_operand: invalid expression as...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.2.0
: P3 normal
Target Milestone: 8.3
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-07 19:04 UTC by Cyril Lashkevich
Modified: 2019-01-08 10:49 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-12-08 00:00:00


Attachments
Preprocessed source to reproduce error (307.55 KB, application/x-gzip)
2018-12-07 19:04 UTC, Cyril Lashkevich
Details
gcc9-pr88410.patch (568 bytes, patch)
2018-12-08 10:44 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cyril Lashkevich 2018-12-07 19:04:40 UTC
Created attachment 45186 [details]
Preprocessed source to reproduce error

I've got ../../runtime/vm/raw_object_fields.cc:218:1: internal compiler error: output_operand: invalid expression as operand when trying to build https://github.com/dart-lang/sdk

Preprocessed source is attached.

Build command is:

g++ -MMD -MF x86/obj/runtime/vm/libdart_vm_nosnapshot_with_precompiler.raw_object_fields.o.d -D_FORTIFY_SOURCE=2 -DNDEBUG -DTARGET_ARCH_ARM -DTARGET_ARCH_ARM_6 -DNDEBUG -DDART_USE_TCMALLOC -DTARGET_OS_LINUX -DDART_NO_SNAPSHOT -DDART_PRECOMPILER -I../../runtime -I../.. -Ix86/gen -I../../runtime/include -I../../third_party/tcmalloc/gperftools/src -m32 -msse2 -mfpmath=sse -fno-exceptions -pthread -Wendif-labels -Wno-missing-field-initializers -Wno-unused-parameter -fdebug-prefix-map=/home/lorca/dart/sdk=../.. -no-canonical-prefixes -O3 -fno-ident -fdata-sections -ffunction-sections -g3 -ggdb3 -Wno-unused-parameter -Wnon-virtual-dtor -Wvla -Wno-conversion-null -Woverloaded-virtual -Wno-comments -g3 -ggdb3 -fno-rtti -fno-exceptions -O3 -fvisibility-inlines-hidden -fno-omit-frame-pointer -std=gnu++11 -fno-rtti -fno-exceptions -c preprocessed.cc

Reproduces on gcc version 8.2.0 (Ubuntu 8.2.0-7ubuntu1) and gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
Comment 1 Jakub Jelinek 2018-12-08 10:20:46 UTC
Reduced testcase:
typedef __UINTPTR_TYPE__ uintptr_t;
const uintptr_t a = 2;
struct C { int b; };
uintptr_t c { uintptr_t (&reinterpret_cast<C *>(a)->b) };

Started with my r259458.
Comment 2 Jakub Jelinek 2018-12-08 10:44:07 UTC
Created attachment 45190 [details]
gcc9-pr88410.patch

Untested fix.  Why doesn't libdart use offsetof though?
Comment 3 Jakub Jelinek 2018-12-17 21:55:09 UTC
Author: jakub
Date: Mon Dec 17 21:54:37 2018
New Revision: 267220

URL: https://gcc.gnu.org/viewcvs?rev=267220&root=gcc&view=rev
Log:
	PR c++/88410
	* cp-gimplify.c (cp_fold) <case ADDR_EXPR>: For offsetof-like folding,
	call maybe_constant_value on val to see if it is INTEGER_CST.

	* g++.dg/cpp0x/pr88410.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr88410.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-gimplify.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Jakub Jelinek 2018-12-17 22:26:33 UTC
Fixed on the trunk so far.
Comment 5 Jakub Jelinek 2019-01-08 10:23:17 UTC
Author: jakub
Date: Tue Jan  8 10:22:44 2019
New Revision: 267710

URL: https://gcc.gnu.org/viewcvs?rev=267710&root=gcc&view=rev
Log:
	Backported from mainline
	2018-12-17  Jakub Jelinek  <jakub@redhat.com>

	PR c++/88410
	* cp-gimplify.c (cp_fold) <case ADDR_EXPR>: For offsetof-like folding,
	call maybe_constant_value on val to see if it is INTEGER_CST.

	* g++.dg/cpp0x/pr88410.C: New test.

Added:
    branches/gcc-8-branch/gcc/testsuite/g++.dg/cpp0x/pr88410.C
Modified:
    branches/gcc-8-branch/gcc/cp/ChangeLog
    branches/gcc-8-branch/gcc/cp/cp-gimplify.c
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
Comment 6 Jakub Jelinek 2019-01-08 10:49:27 UTC
Fixed for 8.3+ too.