public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57509] New: Segmentation fault when using __builtin_shuffle in templated class.
@ 2013-06-03 11:26 beholder0x100 at gmail dot com
  2013-06-08 19:44 ` [Bug c++/57509] " glisse at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: beholder0x100 at gmail dot com @ 2013-06-03 11:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57509

            Bug ID: 57509
           Summary: Segmentation fault when using __builtin_shuffle in
                    templated class.
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: beholder0x100 at gmail dot com

Ubuntu 12.10 64-bit


GCC 4.8.1 which I built from source:
COLLECT_GCC=/opt/custom/gcc-4.8.1/bin/gcc
COLLECT_LTO_WRAPPER=/opt/custom/gcc-4.8.1/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.1/configure --prefix=/opt/custom/gcc-4.8.1
--enable-languages=c,c++
Thread model: posix
gcc version 4.8.1 (GCC) 


/opt/custom/gcc-4.8.1/bin/gcc test.cpp
test.cpp: In static member function ‘static int_v4<Tp>::Tpv
int_v4<Tp>::shuffle(const int_v4<Tp>&, const int_v4<Tp>&, const int_v4<Tp>&)’:
test.cpp:8:49: internal compiler error: Segmentation fault
         return __builtin_shuffle(u1.v, u2.v, s.v);
                                                 ^
0x8d7dff crash_signal
    ../../gcc-4.8.1/gcc/toplev.c:332
0x632761 c_build_vec_perm_expr(unsigned int, tree_node*, tree_node*,
tree_node*)
    ../../gcc-4.8.1/gcc/c-family/c-common.c:2280
0x5965f3 cp_parser_postfix_expression
    ../../gcc-4.8.1/gcc/cp/parser.c:5558
0x5983bd cp_parser_unary_expression
    ../../gcc-4.8.1/gcc/cp/parser.c:6729
0x598eef cp_parser_binary_expression
    ../../gcc-4.8.1/gcc/cp/parser.c:7421
0x59939f cp_parser_assignment_expression
    ../../gcc-4.8.1/gcc/cp/parser.c:7657
0x59af93 cp_parser_expression
    ../../gcc-4.8.1/gcc/cp/parser.c:7819
0x5932ce cp_parser_expression
    ../../gcc-4.8.1/gcc/cp/parser.c:7858
0x5932ce cp_parser_jump_statement
    ../../gcc-4.8.1/gcc/cp/parser.c:10144
0x5932ce cp_parser_statement
    ../../gcc-4.8.1/gcc/cp/parser.c:8874
0x593a8e cp_parser_statement_seq_opt
    ../../gcc-4.8.1/gcc/cp/parser.c:9238
0x593bae cp_parser_compound_statement
    ../../gcc-4.8.1/gcc/cp/parser.c:9192
0x5a1d28 cp_parser_function_body
    ../../gcc-4.8.1/gcc/cp/parser.c:17827
0x5a1d28 cp_parser_ctor_initializer_opt_and_function_body
    ../../gcc-4.8.1/gcc/cp/parser.c:17863
0x5a2a5f cp_parser_function_definition_after_declarator
    ../../gcc-4.8.1/gcc/cp/parser.c:21843
0x58de44 cp_parser_late_parsing_for_member
    ../../gcc-4.8.1/gcc/cp/parser.c:22484
0x58de44 cp_parser_class_specifier_1
    ../../gcc-4.8.1/gcc/cp/parser.c:18586
0x58de44 cp_parser_class_specifier
    ../../gcc-4.8.1/gcc/cp/parser.c:18610
0x58de44 cp_parser_type_specifier
    ../../gcc-4.8.1/gcc/cp/parser.c:13677
0x5a0711 cp_parser_decl_specifier_seq
    ../../gcc-4.8.1/gcc/cp/parser.c:11003
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.


--------- test.cpp ---------
template <typename Tp>
class int_v4
{
    typedef Tp Tpv __attribute__((vector_size(4 * sizeof(Tp))));
    Tpv v;

    static Tpv shuffle(const int_v4& u1, const int_v4& u2, const int_v4& s) {
        return __builtin_shuffle(u1.v, u2.v, s.v); //segfault
    }

    Tpv shuffle2(const int_v4& u1, const int_v4& u2, const int_v4& s) {
        return __builtin_shuffle(v, v, v); //error if shuffle() is removed
    }
};

int main()
{
    int_v4<int> iv4;
    int_v4<unsigned int> uv4;
    return 0;
}

-----------

If: 

    typedef int Tp;

is added at the top and the lines with template stuff are removed then it
compiles just fine but with the use of templates there is a segfault in
shuffle() and if shuffle() is removed then there is: 

    "error: __builtin_shuffle last argument must be an integer vector" 

in shuffle2(). When compiling with GCC 4.7.2 (which is shipping with Ubuntu
12.10) then everything compiles, even if the line:

    int_v4<float> fv4; 

is added to main() (meaning that it was possible to pass non-integer vector as
the last argument of __builtin_shuffle in GCC 4.7.2).

I'm guessing that the bug is somehow related to the presence/addition of error
handling code. It looks like (I am not a GCC developer) GCC is trying to
determine the type of the last argument before any variables using the template
are even defined (they can be removed and the error message will still be
there).
>From gcc-bugs-return-423715-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jun 03 11:29:48 2013
Return-Path: <gcc-bugs-return-423715-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 24057 invoked by alias); 3 Jun 2013 11:29:48 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 24012 invoked by uid 48); 3 Jun 2013 11:29:45 -0000
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/57508] [4.8/4.9 Regression] [OOP] Intrinsic assignment+defined-assignment for comps: PROCEDURE attribute of '_F.DA0' conflicts with VARIABLE attribute
Date: Mon, 03 Jun 2013 11:29:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: ice-on-valid-code, rejects-valid
X-Bugzilla-Severity: normal
X-Bugzilla-Who: burnus at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-57508-4-1TGQAKbfDg@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57508-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57508-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-06/txt/msg00094.txt.bz2
Content-length: 539

http://gcc.gnu.org/bugzilla/show_bug.cgi?idW508

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
I believe that it is not a true regression.

In GCC 4.7, the intrinsic assignment
      create_arbitrary = from_struct()
did also an intrinsic assignment of the "counter" component.

Since Paul's GCC 4.8 patch for PR 46897 (r194016), one now invokes "subroutine
assign" for the "counter" component. - That patch introduced the '@DA0'
temporary, which I changed GCC 4.9's r199215 to be "_F.DA0" to avoid assembler
errors.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/57509] Segmentation fault when using __builtin_shuffle in templated class.
  2013-06-03 11:26 [Bug c++/57509] New: Segmentation fault when using __builtin_shuffle in templated class beholder0x100 at gmail dot com
@ 2013-06-08 19:44 ` glisse at gcc dot gnu.org
  2013-06-08 21:29 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-06-08 19:44 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57509

Marc Glisse <glisse at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-06-08
     Ever confirmed|0                           |1

--- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Paolo Carlini from comment #1)
> Maybe Marc is interested in this.

ChangeLog says this is probably my fault...

c_build_vec_perm_expr is missing some code like we can find in build_x_unary_op
for instance:

  if (processing_template_decl)
    {
      if (type_dependent_expression_p (xarg))
        return build_min_nt_loc (loc, code, xarg, NULL_TREE);

      xarg = build_non_dependent_expr (xarg);
    }

RID_BUILTIN_SHUFFLE is handled very early in parser.c which directly calls
c_build_vec_perm_expr. I guess we could use build_min_nt(VEC_PERM_EXPR,...) to
store the template version, and make sure that c_build_vec_perm_expr is called
once the types are instantiated (in tsubst_copy(_and_build)?).


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/57509] Segmentation fault when using __builtin_shuffle in templated class.
  2013-06-03 11:26 [Bug c++/57509] New: Segmentation fault when using __builtin_shuffle in templated class beholder0x100 at gmail dot com
  2013-06-08 19:44 ` [Bug c++/57509] " glisse at gcc dot gnu.org
@ 2013-06-08 21:29 ` paolo.carlini at oracle dot com
  2013-06-08 21:41 ` glisse at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-06-08 21:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57509

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Thanks Marc. Please take your own plan very seriously! ;)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/57509] Segmentation fault when using __builtin_shuffle in templated class.
  2013-06-03 11:26 [Bug c++/57509] New: Segmentation fault when using __builtin_shuffle in templated class beholder0x100 at gmail dot com
  2013-06-08 19:44 ` [Bug c++/57509] " glisse at gcc dot gnu.org
  2013-06-08 21:29 ` paolo.carlini at oracle dot com
@ 2013-06-08 21:41 ` glisse at gcc dot gnu.org
  2013-06-09  9:05 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-06-08 21:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57509

--- Comment #4 from Marc Glisse <glisse at gcc dot gnu.org> ---
Created attachment 30281
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30281&action=edit
Untested patch

There are quite a few issues with the c++ version...


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/57509] Segmentation fault when using __builtin_shuffle in templated class.
  2013-06-03 11:26 [Bug c++/57509] New: Segmentation fault when using __builtin_shuffle in templated class beholder0x100 at gmail dot com
                   ` (2 preceding siblings ...)
  2013-06-08 21:41 ` glisse at gcc dot gnu.org
@ 2013-06-09  9:05 ` paolo.carlini at oracle dot com
  2013-06-09  9:15 ` glisse at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-06-09  9:05 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57509

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Detail: normally we just pass around tsubst_flags_ts, no complain & tf_error to
bool, etc.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/57509] Segmentation fault when using __builtin_shuffle in templated class.
  2013-06-03 11:26 [Bug c++/57509] New: Segmentation fault when using __builtin_shuffle in templated class beholder0x100 at gmail dot com
                   ` (3 preceding siblings ...)
  2013-06-09  9:05 ` paolo.carlini at oracle dot com
@ 2013-06-09  9:15 ` glisse at gcc dot gnu.org
  2013-06-09 11:29 ` paolo.carlini at oracle dot com
  2013-06-27 21:31 ` glisse at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-06-09  9:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57509

--- Comment #6 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Paolo Carlini from comment #5)
> Detail: normally we just pass around tsubst_flags_ts, no complain & tf_error
> to bool, etc.

Those flags are not available in c-family, this is not the first place where we
pass a bool in this case.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/57509] Segmentation fault when using __builtin_shuffle in templated class.
  2013-06-03 11:26 [Bug c++/57509] New: Segmentation fault when using __builtin_shuffle in templated class beholder0x100 at gmail dot com
                   ` (4 preceding siblings ...)
  2013-06-09  9:15 ` glisse at gcc dot gnu.org
@ 2013-06-09 11:29 ` paolo.carlini at oracle dot com
  2013-06-27 21:31 ` glisse at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-06-09 11:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57509

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> ---
I see, I never fiddled with those.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/57509] Segmentation fault when using __builtin_shuffle in templated class.
  2013-06-03 11:26 [Bug c++/57509] New: Segmentation fault when using __builtin_shuffle in templated class beholder0x100 at gmail dot com
                   ` (5 preceding siblings ...)
  2013-06-09 11:29 ` paolo.carlini at oracle dot com
@ 2013-06-27 21:31 ` glisse at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-06-27 21:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57509

Marc Glisse <glisse at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Marc Glisse <glisse at gcc dot gnu.org> ---
r200495 | glisse | 2013-06-27 23:29:22 +0200 (Thu, 27 Jun 2013) | 20 lines

2013-06-27  Marc Glisse  <marc.glisse@inria.fr>

        PR c++/57509

gcc/c-family/
        * c-common.h (c_build_vec_perm_expr): New complain argument.
        * c-common.c (c_build_vec_perm_expr): Likewise.
        Use save_expr also in C++.

gcc/cp/
        * typeck.c (cp_build_vec_perm_expr): New function.
        * cp-tree.h: Declare it.
        * parser.c (cp_parser_postfix_expression): Call it.
        * pt.c (tsubst_copy): Handle VEC_PERM_EXPR.
        (tsubst_copy_and_build): Likewise.

gcc/testsuite/
        * g++.dg/ext/pr57509.C: New file.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-06-27 21:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-03 11:26 [Bug c++/57509] New: Segmentation fault when using __builtin_shuffle in templated class beholder0x100 at gmail dot com
2013-06-08 19:44 ` [Bug c++/57509] " glisse at gcc dot gnu.org
2013-06-08 21:29 ` paolo.carlini at oracle dot com
2013-06-08 21:41 ` glisse at gcc dot gnu.org
2013-06-09  9:05 ` paolo.carlini at oracle dot com
2013-06-09  9:15 ` glisse at gcc dot gnu.org
2013-06-09 11:29 ` paolo.carlini at oracle dot com
2013-06-27 21:31 ` glisse at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).