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

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).