public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56970] New: SFINAE does not apply correctly to sizeof.
@ 2013-04-15 14:36 yufanyufan at gmail dot com
  2013-04-15 15:07 ` [Bug c++/56970] " yufanyufan at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: yufanyufan at gmail dot com @ 2013-04-15 14:36 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56970
           Summary: SFINAE does not apply correctly to sizeof.
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: yufanyufan@gmail.com


This code compiles with g++ 4.7.3, clang 3.2, but not g++ 4.8.
Error is:
In substitution of ‘template<class C> static constexpr int
has<T>::test(decltype (sizeof (C:: x))) [with C = C; T = foo] [with C = foo]’:
required from ‘const int foobar<foo>::value’
required from here
error: invalid use of non-static member function ‘int foo::x()’

#include <string>
#include <iostream>
template <typename T>
struct has {
    template <typename>
    constexpr static int test(...) {
      return 0;
    }
    template <typename C>
    constexpr static int test(decltype(sizeof(C::x))) {  // Doesn't compile.
      return 1;   // Is a member variable.
    }
    template <typename C, int c =
        sizeof(decltype(((C*)nullptr)->x()))>
    constexpr static int test(int) {
      return 2;   // Is a member function.
    }
    static const int value = test<T>(0);
};
struct foo {
    int x();
};
struct bar {
    int x;
};
int main() {
    std::cout << has<int>::value << std::endl;
    std::cout << has<foo>::value << std::endl;
    std::cout << has<bar>::value << std::endl;
}
>From gcc-bugs-return-420326-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Apr 15 14:38:44 2013
Return-Path: <gcc-bugs-return-420326-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 28243 invoked by alias); 15 Apr 2013 14:38:44 -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 28209 invoked by uid 48); 15 Apr 2013 14:38:41 -0000
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/56935] Basic block is not SLP-vectorizeed after r197635.
Date: Mon, 15 Apr 2013 14:38:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rguenth at gcc dot gnu.org
X-Bugzilla-Status: WAITING
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields: Status
Message-ID: <bug-56935-4-AkgZJegkUJ@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-56935-4@http.gcc.gnu.org/bugzilla/>
References: <bug-56935-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
X-SW-Source: 2013-04/txt/msg01471.txt.bz2
Content-length: 1517


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |WAITING

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> 2013-04-15 14:38:40 UTC ---
Reduced testcase:

typedef struct {
  long int x;
  long int y;
} S;
void foo (S *s)
{
    s->x--;
    s->y--;
}

Difference in cost model analysis:

before:

t.c:7: note: Cost model analysis:
  Vector inside of basic block cost: 5
  Vector prologue cost: 0
  Vector epilogue cost: 0
  Scalar cost of basic block: 6

after:

t.c:7: note: Cost model analysis:
  Vector inside of basic block cost: 5
  Vector prologue cost: 1
  Vector epilogue cost: 0
  Scalar cost of basic block: 6

after is more correct, as we need to synthesize the { 1, 1 } vector.
what isn't really optimal is the unchanged vector inside cost.
It's an unaligned load with cost 2, the vector operation with cost 1
and the unaligned store with cost 2.

Before we generated

        pcmpeqd %xmm0, %xmm0
        movdqu  (%rdi), %xmm1
        paddq   %xmm1, %xmm0
        movdqu  %xmm0, (%rdi)
        ret

and afterwards

        subq    $1, (%rdi)
        subq    $1, 8(%rdi)

I'd say it's obvious that the non-vectorized variant is better.

So, are you sure _this_ basic-block is really the issue?


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

* [Bug c++/56970] SFINAE does not apply correctly to sizeof.
  2013-04-15 14:36 [Bug c++/56970] New: SFINAE does not apply correctly to sizeof yufanyufan at gmail dot com
@ 2013-04-15 15:07 ` yufanyufan at gmail dot com
  2013-04-15 16:50 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: yufanyufan at gmail dot com @ 2013-04-15 15:07 UTC (permalink / raw)
  To: gcc-bugs


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

Fan Yu <yufanyufan at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |major


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

* [Bug c++/56970] SFINAE does not apply correctly to sizeof.
  2013-04-15 14:36 [Bug c++/56970] New: SFINAE does not apply correctly to sizeof yufanyufan at gmail dot com
  2013-04-15 15:07 ` [Bug c++/56970] " yufanyufan at gmail dot com
@ 2013-04-15 16:50 ` jakub at gcc dot gnu.org
  2013-04-24 10:01 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-04-15 16:50 UTC (permalink / raw)
  To: gcc-bugs


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-04-15 16:50:36 UTC ---
Started with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190830
By using __builtin_printf or static_assert one can avoid all the includes.


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

* [Bug c++/56970] SFINAE does not apply correctly to sizeof.
  2013-04-15 14:36 [Bug c++/56970] New: SFINAE does not apply correctly to sizeof yufanyufan at gmail dot com
  2013-04-15 15:07 ` [Bug c++/56970] " yufanyufan at gmail dot com
  2013-04-15 16:50 ` jakub at gcc dot gnu.org
@ 2013-04-24 10:01 ` paolo.carlini at oracle dot com
  2013-04-24 10:20 ` paolo.carlini at oracle dot com
  2013-04-24 15:43 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-04-24 10:01 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-04-24
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com
     Ever Confirmed|0                           |1

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-04-24 10:01:53 UTC ---
Seems simple: missing propagation of complain.


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

* [Bug c++/56970] SFINAE does not apply correctly to sizeof.
  2013-04-15 14:36 [Bug c++/56970] New: SFINAE does not apply correctly to sizeof yufanyufan at gmail dot com
                   ` (2 preceding siblings ...)
  2013-04-24 10:01 ` paolo.carlini at oracle dot com
@ 2013-04-24 10:20 ` paolo.carlini at oracle dot com
  2013-04-24 15:43 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-04-24 10:20 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |normal


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

* [Bug c++/56970] SFINAE does not apply correctly to sizeof.
  2013-04-15 14:36 [Bug c++/56970] New: SFINAE does not apply correctly to sizeof yufanyufan at gmail dot com
                   ` (3 preceding siblings ...)
  2013-04-24 10:20 ` paolo.carlini at oracle dot com
@ 2013-04-24 15:43 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-04-24 15:43 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.8.1

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-04-24 15:43:16 UTC ---
Fixed mainline and 4.8.1.


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

end of thread, other threads:[~2013-04-24 15:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-15 14:36 [Bug c++/56970] New: SFINAE does not apply correctly to sizeof yufanyufan at gmail dot com
2013-04-15 15:07 ` [Bug c++/56970] " yufanyufan at gmail dot com
2013-04-15 16:50 ` jakub at gcc dot gnu.org
2013-04-24 10:01 ` paolo.carlini at oracle dot com
2013-04-24 10:20 ` paolo.carlini at oracle dot com
2013-04-24 15:43 ` paolo.carlini at oracle dot com

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