public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57846] New: CRTP, templates, metaprogramming, forwarding and static member
@ 2013-07-08  0:15 vince.rev at gmail dot com
  2013-07-16  9:57 ` [Bug c++/57846] " vince.rev at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: vince.rev at gmail dot com @ 2013-07-08  0:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57846
           Summary: CRTP, templates, metaprogramming, forwarding and
                    static member
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vince.rev at gmail dot com

This code (I could not find a simpler example) does not compile under g++ for
some obscure reasons (tested with 4.8.1 and 4.7.2) (see the related discussion
on stack overflow here :
http://stackoverflow.com/questions/17515079/crtp-templates-metaprogramming-forwarding-and-static-member-a-bug-in-g-4-8):

-------------------------------------------------------------
#include <iostream>
#include <type_traits>
#include <utility>
#include <tuple>
#include <array>

template <class Crtp, class... Types> struct Base
{
    template <unsigned int Index, class Type = typename
std::tuple_element<Index, std::tuple<Types...> >::type> inline const Type&
get() const {return std::get<Index>(data);}
    template <unsigned int Index, class Type = typename
std::tuple_element<Index, std::tuple<Types...> >::type> inline Crtp& set(const
Type& value) {std::get<Index>(data) = value; return static_cast<Crtp&>(*this);}
    std::tuple<Types...> data;
};

template <typename Type, unsigned int Size> struct Derived : public
Base<Derived<Type, Size>, std::array<Type, Size>>
{
    template <class... Args, class Template = decltype(std::declval<const
Base<Derived<Type, Size>, std::array<Type, Size>>>().template
get<0>(std::declval<Args>()...))> inline Template test(Args&&... args) const
{return this->template get<0>(std::forward<Args>(args)...);} 
    template <class... Args, class Template = decltype(std::declval<const
Base<Derived<Type, Size>, std::array<Type, Size>>>().template
set<0>(std::declval<Args>()...))> inline Derived<Type, Size>& test(Args&&...
args) {return this->template set<0>(std::forward<Args>(args)...);} 
    static void check() {Derived<double, 3> derived;
std::cout<<derived.test()[0]<<std::endl;}
};

int main(int argc, char* argv[])
{
    Derived<double, 3> derived; std::cout<<derived.test()[0]<<std::endl; //
Working
    Derived<double, 3>::check(); // Not working: error: no match for
‘operator[]’ (operand types are ‘Derived<double, 3u>’ and ‘int’)
    return 0;
}

-------------------------------------------------------------
>From gcc-bugs-return-425895-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jul 08 03:22:59 2013
Return-Path: <gcc-bugs-return-425895-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 6919 invoked by alias); 8 Jul 2013 03:22:59 -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 6890 invoked by uid 48); 8 Jul 2013 03:22:55 -0000
From: "lxz at knd dot com.cn" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/57847] New: Compile ARM linux kernel with configuration of SLUB allocator, kernel failed to boot
Date: Mon, 08 Jul 2013 03:22:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: 4.7.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: lxz at knd dot com.cn
X-Bugzilla-Status: UNCONFIRMED
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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-57847-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-07/txt/msg00402.txt.bz2
Content-length: 667

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

            Bug ID: 57847
           Summary: Compile ARM linux kernel with configuration of SLUB
                    allocator, kernel failed to boot
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lxz at knd dot com.cn

Tested kernel version is 3.2.21 and 3.2. Kernel encounters "data abort" during
initiation.
Problem exists in gcc 4.7.3 and 4.8.1, but 4.6.3 works fine.
Changing kernel configuration to SLAB allocator is a workaround.


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

* [Bug c++/57846] CRTP, templates, metaprogramming, forwarding and static member
  2013-07-08  0:15 [Bug c++/57846] New: CRTP, templates, metaprogramming, forwarding and static member vince.rev at gmail dot com
@ 2013-07-16  9:57 ` vince.rev at gmail dot com
  2014-12-12 15:18 ` ville.voutilainen at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: vince.rev at gmail dot com @ 2013-07-16  9:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Vincent <vince.rev at gmail dot com> ---
Apparently, this is also a bug in the last version (4.9):
http://stackoverflow.com/questions/17515079/crtp-templates-metaprogramming-forwarding-and-static-member-a-bug-in-g-4-8


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

* [Bug c++/57846] CRTP, templates, metaprogramming, forwarding and static member
  2013-07-08  0:15 [Bug c++/57846] New: CRTP, templates, metaprogramming, forwarding and static member vince.rev at gmail dot com
  2013-07-16  9:57 ` [Bug c++/57846] " vince.rev at gmail dot com
@ 2014-12-12 15:18 ` ville.voutilainen at gmail dot com
  2014-12-13 16:42 ` harald at gigawatt dot nl
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-12-12 15:18 UTC (permalink / raw)
  To: gcc-bugs

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

Ville Voutilainen <ville.voutilainen at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-12-12
                 CC|                            |ville.voutilainen at gmail dot com
     Ever confirmed|0                           |1
      Known to fail|                            |4.8.2, 4.9.1, 5.0

--- Comment #2 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
We badly need a reduced testcase for this.


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

* [Bug c++/57846] CRTP, templates, metaprogramming, forwarding and static member
  2013-07-08  0:15 [Bug c++/57846] New: CRTP, templates, metaprogramming, forwarding and static member vince.rev at gmail dot com
  2013-07-16  9:57 ` [Bug c++/57846] " vince.rev at gmail dot com
  2014-12-12 15:18 ` ville.voutilainen at gmail dot com
@ 2014-12-13 16:42 ` harald at gigawatt dot nl
  2021-08-10  0:37 ` pinskia at gcc dot gnu.org
  2021-08-13 22:59 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: harald at gigawatt dot nl @ 2014-12-13 16:42 UTC (permalink / raw)
  To: gcc-bugs

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

Harald van Dijk <harald at gigawatt dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |harald at gigawatt dot nl

--- Comment #3 from Harald van Dijk <harald at gigawatt dot nl> ---
Somewhat reduced:

template <typename T>
struct A
{
  template <typename T2>
  void f();
};

template <typename T>
struct B
{
  int &f() const;

  template <typename T2 = T, typename = decltype(A<T2>().template f<T2>(T2()))>
  void f();

  void g() {
    int *i = &B<int>().f();
  }
};

Accepted by clang 3.4.2, rejected by gcc 4.8.3 and 4.9.0 with:

test.cc: In member function ‘void B<T>::g()’:
test.cc:17:26: error: lvalue required as unary ‘&’ operand

It seems to only happen when certain operators are used: there is no error when
doing e.g.

  int &i = B<int>().f();
>From gcc-bugs-return-470540-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Dec 13 16:48:09 2014
Return-Path: <gcc-bugs-return-470540-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 7700 invoked by alias); 13 Dec 2014 16:48:08 -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 7632 invoked by uid 48); 13 Dec 2014 16:48:04 -0000
From: "danglin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/64298] New: [5 Regression] ICE: Segmentation fault in get_binfo_at_offset at tree.c:11914
Date: Sat, 13 Dec 2014 16:48:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: ipa
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: danglin at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cf_gcchost cf_gcctarget cf_gccbuild
Message-ID: <bug-64298-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: 2014-12/txt/msg01547.txt.bz2
Content-length: 2288

https://gcc.gnu.org/bugzilla/show_bug.cgi?idd298

            Bug ID: 64298
           Summary: [5 Regression] ICE: Segmentation fault in
                    get_binfo_at_offset at tree.c:11914
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: danglin at gcc dot gnu.org
              Host: hppa-unknown-linux-gnu
            Target: hppa-unknown-linux-gnu
             Build: hppa-unknown-linux-gnu

In r218651, the following ICE occurs:

spawn /home/dave/gnu/gcc/objdir/gcc/testsuite/g++/../../xg++
-B/home/dave/gnu/gc
c/objdir/gcc/testsuite/g++/../../
/home/dave/gnu/gcc/gcc/gcc/testsuite/g++.dg/ip
a/pr64059.C -fno-diagnostics-show-caret -fdiagnostics-color=never -nostdinc++
-I/home/dave/gnu/gcc/objdir/hppa-linux-gnu/libstdc++-v3/include/hppa-linux-gnu
-I/
home/dave/gnu/gcc/objdir/hppa-linux-gnu/libstdc++-v3/include
-I/home/dave/gnu/gc
c/gcc/libstdc++-v3/libsupc++
-I/home/dave/gnu/gcc/gcc/libstdc++-v3/include/backw
ard -I/home/dave/gnu/gcc/gcc/libstdc++-v3/testsuite/util -fmessage-length=0
-std
=gnu++98 -r -nostdlib -O2 -flto -fno-devirtualize -S -o pr64059.s
/home/dave/gnu/gcc/gcc/gcc/testsuite/g++.dg/ipa/pr64059.C:56:1: internal
compiler error: Segmentation fault
0x685e57 crash_signal
        ../../gcc/gcc/toplev.c:358
0x894508 get_binfo_at_offset(tree_node*, long long, tree_node*)
        ../../gcc/gcc/tree.c:11914
0x4d044f possible_polymorphic_call_targets(tree_node*, long long,
ipa_polymorphi
c_call_context, bool*, void**, bool)
        ../../gcc/gcc/ipa-devirt.c:2404
0x5661db possible_polymorphic_call_targets(cgraph_edge*, bool*, void**, bool)
        ../../gcc/gcc/ipa-utils.h:109
0x5661db compute_ltrans_boundary(lto_symtab_encoder_d*)
        ../../gcc/gcc/lto-cgraph.c:952
0x5bfabb ipa_write_summaries(bool)
        ../../gcc/gcc/passes.c:2511
0x327e53 ipa_passes
        ../../gcc/gcc/cgraphunit.c:2093
0x327e53 symbol_table::compile()
        ../../gcc/gcc/cgraphunit.c:2189
0x32936b symbol_table::finalize_compilation_unit()
        ../../gcc/gcc/cgraphunit.c:2338
0x191527 cp_write_global_declarations()
        ../../gcc/gcc/cp/decl2.c:4688
Please submit a full bug report,


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

* [Bug c++/57846] CRTP, templates, metaprogramming, forwarding and static member
  2013-07-08  0:15 [Bug c++/57846] New: CRTP, templates, metaprogramming, forwarding and static member vince.rev at gmail dot com
                   ` (2 preceding siblings ...)
  2014-12-13 16:42 ` harald at gigawatt dot nl
@ 2021-08-10  0:37 ` pinskia at gcc dot gnu.org
  2021-08-13 22:59 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-10  0:37 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=83160

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed in GCC 8, most likely by the patch which fixed PR 83160.

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

* [Bug c++/57846] CRTP, templates, metaprogramming, forwarding and static member
  2013-07-08  0:15 [Bug c++/57846] New: CRTP, templates, metaprogramming, forwarding and static member vince.rev at gmail dot com
                   ` (3 preceding siblings ...)
  2021-08-10  0:37 ` pinskia at gcc dot gnu.org
@ 2021-08-13 22:59 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-13 22:59 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |8.3

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

end of thread, other threads:[~2021-08-13 22:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-08  0:15 [Bug c++/57846] New: CRTP, templates, metaprogramming, forwarding and static member vince.rev at gmail dot com
2013-07-16  9:57 ` [Bug c++/57846] " vince.rev at gmail dot com
2014-12-12 15:18 ` ville.voutilainen at gmail dot com
2014-12-13 16:42 ` harald at gigawatt dot nl
2021-08-10  0:37 ` pinskia at gcc dot gnu.org
2021-08-13 22:59 ` pinskia 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).