public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64514] New: Error in template instantiation in GCC 4.9, works fine in GCC 4.8
@ 2015-01-06 20:37 freddie_chopin at op dot pl
  2015-01-12 16:32 ` [Bug c++/64514] " ville.voutilainen at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: freddie_chopin at op dot pl @ 2015-01-06 20:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64514
           Summary: Error in template instantiation in GCC 4.9, works fine
                    in GCC 4.8
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: freddie_chopin at op dot pl

The test code below works perfectly fine with GCC 4.8 (and 4.7):

--- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 ---

#include <type_traits>

template<typename T, T &object, typename... Args>
struct Functor
{
    template<float (T::*function)(Args...), Args... args>
    struct Inner
    {
        float operator()() const
        {
            return (object.*function)(args...);
        }
    };
};

class Object
{
public:

    float someFunction()
    {
        return {};
    }

    float someFunctionWithArgument(int)
    {
        return {};
    }
};

Object object;

Functor<Object, object>::Inner<&Object::someFunction> functor1;
Functor<Object, object, int>::Inner<&Object::someFunctionWithArgument, 1>
functor2;

int main()
{

}

--- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 ---

However with GCC 4.9 it fails with a rather unhelpful message at the point of
instantiation of functor1:

--- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 ---

$ g++ -std=c++11 test.cpp 
test.cpp: In instantiation of ‘struct Functor<Object, (* & object)>’:
test.cpp:33:24:   required from here
test.cpp:7:9: error: wrong number of template arguments (2, should be 1)
  struct Inner
         ^
test.cpp:7:9: error: provided for ‘template<class T, T& object, class ... Args>
template<float (T::* function)(Args ...), Args ...args> struct Functor<T,
object, Args>::Inner’
test.cpp:7:9: error: wrong number of template arguments (2, should be 1)
test.cpp:7:9: error: provided for ‘template<class T, T& object, class ... Args>
template<float (T::* function)(Args ...), Args ...args> struct Functor<T,
object, Args>::Inner’
test.cpp:33:26: error: ‘Inner’ in ‘struct Functor<Object, (* & object)>’ does
not name a template type
 Functor<Object, object>::Inner<&Object::someFunction> functor1;
                          ^

--- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 ---

If I comment the line with functor1 instantiation, everything else (functor2)
works fine.

At the stackoverflow question I asked (
http://stackoverflow.com/questions/27802404/error-in-template-instantiation-in-gcc-4-9-works-fine-in-gcc-4-8?noredirect=1#comment44015634_27802404
) it was reported that clang 3.5 and Visual Studio 2015 Preview accept this
code, while intel 14 errors out (with an unreported message) and solaris studio
12.4 crashes.

Is there something wrong with this code (which was working for me for over 2
years with older versions) or maybe this is a regression?
>From gcc-bugs-return-472335-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jan 06 20:45:12 2015
Return-Path: <gcc-bugs-return-472335-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 16897 invoked by alias); 6 Jan 2015 20:45:11 -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 16405 invoked by uid 55); 6 Jan 2015 20:45:06 -0000
From: "jason at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/64489] A simple struct wrapping a const int is not trivially copyable
Date: Tue, 06 Jan 2015 20:45:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords: rejects-valid
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jason at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: ville.voutilainen at gmail dot com
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-64489-4-dHqMpj59bP@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64489-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64489-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: 2015-01/txt/msg00329.txt.bz2
Content-length: 495

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

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Tue Jan  6 20:44:32 2015
New Revision: 219265

URL: https://gcc.gnu.org/viewcvs?rev!9265&root=gcc&view=rev
Log:
    PR c++/64489
    * class.c (check_field_decls): Make copy assignment operators
    complex only in c++98 mode.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/testsuite/g++.dg/ext/is_trivially_constructible1.C


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

* [Bug c++/64514] Error in template instantiation in GCC 4.9, works fine in GCC 4.8
  2015-01-06 20:37 [Bug c++/64514] New: Error in template instantiation in GCC 4.9, works fine in GCC 4.8 freddie_chopin at op dot pl
@ 2015-01-12 16:32 ` ville.voutilainen at gmail dot com
  2015-01-12 20:54 ` [Bug c++/64514] [4.9/5 Regression] " freddie_chopin at op dot pl
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ville.voutilainen at gmail dot com @ 2015-01-12 16:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

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


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

* [Bug c++/64514] [4.9/5 Regression] Error in template instantiation in GCC 4.9, works fine in GCC 4.8
  2015-01-06 20:37 [Bug c++/64514] New: Error in template instantiation in GCC 4.9, works fine in GCC 4.8 freddie_chopin at op dot pl
  2015-01-12 16:32 ` [Bug c++/64514] " ville.voutilainen at gmail dot com
@ 2015-01-12 20:54 ` freddie_chopin at op dot pl
  2015-01-13 21:05 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: freddie_chopin at op dot pl @ 2015-01-12 20:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Freddie Chopin <freddie_chopin at op dot pl> ---
The question at stackoverflow has an answer with much simpler test-case which
also shows the problem. http://stackoverflow.com/a/27810002/157344

--- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 ---

template<typename... T>
struct Functor
{
    template <T...>
    struct Inner
    {};
};

template struct Functor<>::Inner<>;

int main()
{

}

--- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 ---

Compiled with GCC 4.9.2:

--- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 ---

$ g++ -std=c++11 test.cpp 
test.cpp: In instantiation of ‘struct Functor<>’:
test.cpp:9:26:   required from here
test.cpp:5:12: error: wrong number of template arguments (1, should be 0)
     struct Inner
            ^
test.cpp:5:12: error: provided for ‘template<class ... T> template<T
...<anonymous> > struct Functor<T>::Inner’
test.cpp:5:12: error: wrong number of template arguments (1, should be 0)
test.cpp:5:12: error: provided for ‘template<class ... T> template<T
...<anonymous> > struct Functor<T>::Inner’
test.cpp:9:28: error: ‘Inner’ is not a class template
 template struct Functor<>::Inner<>;
                            ^
test.cpp:9:28: error: ‘Inner’ in ‘struct Functor<>’ does not name a type

--- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 --- >8 ---

Works fine with GCC 4.8.

The answer also suggests there might be another similar bug, possibly related
to the first one.
>From gcc-bugs-return-472877-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jan 12 21:05:24 2015
Return-Path: <gcc-bugs-return-472877-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 28812 invoked by alias); 12 Jan 2015 21:05:23 -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 28749 invoked by uid 48); 12 Jan 2015 21:05:17 -0000
From: "glisse at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/64454] optimize (x%5)%5
Date: Mon, 12 Jan 2015 21:05: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-Version: 5.0
X-Bugzilla-Keywords: missed-optimization
X-Bugzilla-Severity: normal
X-Bugzilla-Who: glisse 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-64454-4-ZEtTp4Rexm@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64454-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64454-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: 2015-01/txt/msg00871.txt.bz2
Content-length: 913

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

--- Comment #6 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #5)
> The reason for tree_int_cst_sgn (vr->min) >= 0 was that I don't want to let
> 0 through and for negative values, handling those would require computing
> absolute value, but as match.pd already folds x % -5 already into x % 5,
> there is no need to bother with it, so I'm just trying to play safe.

I don't think we are talking about the same thing. Restricting to positive op1
is good. What I find a little strange is:

+      if (TYPE_UNSIGNED (TREE_TYPE (op0))
+      || tree_int_cst_sgn (vr->min) >= 0
+      || tree_int_cst_lt (fold_unary (NEGATE_EXPR, TREE_TYPE (op1), op1),
+                  vr->min))

where condition 2: min>=0 is more restrictive than condition 3: min>-op1 (since
op1 is known to be positive) so we could skip condition 2.


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

* [Bug c++/64514] [4.9/5 Regression] Error in template instantiation in GCC 4.9, works fine in GCC 4.8
  2015-01-06 20:37 [Bug c++/64514] New: Error in template instantiation in GCC 4.9, works fine in GCC 4.8 freddie_chopin at op dot pl
  2015-01-12 16:32 ` [Bug c++/64514] " ville.voutilainen at gmail dot com
  2015-01-12 20:54 ` [Bug c++/64514] [4.9/5 Regression] " freddie_chopin at op dot pl
@ 2015-01-13 21:05 ` jason at gcc dot gnu.org
  2015-01-28 17:21 ` jason at gcc dot gnu.org
  2015-01-28 17:22 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2015-01-13 21:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Tue Jan 13 21:04:35 2015
New Revision: 219558

URL: https://gcc.gnu.org/viewcvs?rev=219558&root=gcc&view=rev
Log:
    PR c++/64514
    * pt.c (coerce_template_parameter_pack): Return NULL for a
    zero-length fixed parameter pack with a pack expansion arg.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic165.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c


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

* [Bug c++/64514] [4.9/5 Regression] Error in template instantiation in GCC 4.9, works fine in GCC 4.8
  2015-01-06 20:37 [Bug c++/64514] New: Error in template instantiation in GCC 4.9, works fine in GCC 4.8 freddie_chopin at op dot pl
                   ` (2 preceding siblings ...)
  2015-01-13 21:05 ` jason at gcc dot gnu.org
@ 2015-01-28 17:21 ` jason at gcc dot gnu.org
  2015-01-28 17:22 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2015-01-28 17:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Wed Jan 28 17:21:06 2015
New Revision: 220210

URL: https://gcc.gnu.org/viewcvs?rev=220210&root=gcc&view=rev
Log:
    PR c++/64514
    * pt.c (coerce_template_parameter_pack): Return NULL for a
    zero-length fixed parameter pack with a pack expansion arg.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp0x/variadic165.C
Modified:
    branches/gcc-4_9-branch/gcc/cp/ChangeLog
    branches/gcc-4_9-branch/gcc/cp/pt.c


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

* [Bug c++/64514] [4.9/5 Regression] Error in template instantiation in GCC 4.9, works fine in GCC 4.8
  2015-01-06 20:37 [Bug c++/64514] New: Error in template instantiation in GCC 4.9, works fine in GCC 4.8 freddie_chopin at op dot pl
                   ` (3 preceding siblings ...)
  2015-01-28 17:21 ` jason at gcc dot gnu.org
@ 2015-01-28 17:22 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2015-01-28 17:22 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
   Target Milestone|---                         |4.9.3

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 4.9.3/5


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

end of thread, other threads:[~2015-01-28 17:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-06 20:37 [Bug c++/64514] New: Error in template instantiation in GCC 4.9, works fine in GCC 4.8 freddie_chopin at op dot pl
2015-01-12 16:32 ` [Bug c++/64514] " ville.voutilainen at gmail dot com
2015-01-12 20:54 ` [Bug c++/64514] [4.9/5 Regression] " freddie_chopin at op dot pl
2015-01-13 21:05 ` jason at gcc dot gnu.org
2015-01-28 17:21 ` jason at gcc dot gnu.org
2015-01-28 17:22 ` jason 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).