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

            Bug ID: 86669
           Summary: [5/6/7/8/9 regression] Complete object constructor
                    clone omits length for a c++11 braced initialiser
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iains at gcc dot gnu.org
  Target Milestone: ---

Created attachment 44435
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44435&action=edit
pre-processed and reduced code

This applies to targets that do not allow (or have) alias support for
constructor clones.

c-reduce has obfuscated the variable names in the reduced code, of course ...

The original code looks like this:

====

AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST) 
  : LegalizerInfo()  {
  const LLT p0 = LLT::pointer(0, 64);
  const LLT s1 = LLT::scalar(1);
  const LLT s8 = LLT::scalar(8);
  const LLT s16 = LLT::scalar(16);
  const LLT s32 = LLT::scalar(32);
  const LLT s64 = LLT::scalar(64);
  const LLT s128 = LLT::scalar(128);
  const LLT v2s32 = LLT::vector(2, 32);
  const LLT v4s32 = LLT::vector(4, 32);
  const LLT v2s64 = LLT::vector(2, 64);

  for (auto Ty : {p0, s1, s8, s16, s32, s64})
    setAction({/*G_IMPLICIT_DEF*/41, Ty}, Legal);

...
 }
=====

The gimple for the base constructor contains:

"

                try
                  {
                    D.2730 = {};
                    D.2730.i = 6; <<<<< OK _M_len is set
                    D.2729[0] = e;
                    D.2729[1] = f;
                    D.2729[2] = g;
                    D.2729[3] = h;
                    D.2729[4] = i;
                    D.2729[5] = j;
                    D.2730.a = &D.2729;
                    __for_range = &D.2730;
                    __for_begin = std::initializer_list<llvm::J>::begin
(__for_range);
                    __for_end = std::initializer_list<llvm::J>::end
(__for_range);

"

but for the complete constructor:

"
                try
                  {
                    D.2745 = {}; <<< _M_len init missing 
                    D.2744[0] = e;
                    D.2744[1] = f;
                    D.2744[2] = g;
                    D.2744[3] = h;
                    D.2744[4] = i;
                    D.2744[5] = j;
                    D.2745.a = &D.2744;
                    __for_range = &D.2745;
                    __for_begin = std::initializer_list<llvm::J>::begin
(__for_range);
                    __for_end = std::initializer_list<llvm::J>::end
(__for_range);
                    <D.2808>:

"

========

With clang 
.../bin/clang -cc1 -triple x86_64-apple-macosx10.12.0 -x c++-cpp-output
AArch64LegalizerInfo-fmt.ii -O0 -S -std=c++11 -fvisibility-inlines-hidden
-fno-rtti -o tc.s

The complete constructor is rendered as a thunk calling the base constructor
(not sure why we conclude this is not viable in GCC)

======

With GCC (all versions I've tried 5...trunk) we get the effect above.

.../libexec/gcc/x86_64-apple-darwin14/7.3.0/cc1plus -fpreprocessed
AArch64LegalizerInfo-fmt.ii -fPIC -quiet  -mmacosx-version-min=10.10 
-mtune=core2  -g3 -O0 -Werror=date-time -Wall -Wextra -Wno-unused-parameter
-Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wpedantic
-Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment
-std=c++11 -fPIC -fvisibility-inlines-hidden -fno-exceptions -fno-rtti  -o tg.s 

======

I took a look at what was happening in cp/optimize.c:maybe_clone_body() but
couldn't see any special difference between the operations carried out to clone
the base and the complete constructors.

Reply via email to