public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation
@ 2014-08-25 13:52 m at maxgerlach dot de
2014-08-25 14:15 ` [Bug c++/62255] Introducing an unrelated template parameter causes compilation to fail conradsand.arma at gmail dot com
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: m at maxgerlach dot de @ 2014-08-25 13:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255
Bug ID: 62255
Summary: Introducing an unrelated template parameter causes
failed compilation
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: m at maxgerlach dot de
Created attachment 33393
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33393&action=edit
Archive containing output.txt, arma_template_test.ii and
arma_no_template_test.ii
Adding a template parameter to a class causes compilation to fail, even though
no further use of this parameter is made.
This problem shows up by using any recent release of the Armadillo C++ library
(header only, http://arma.sourceforge.net/) with gcc 4.8.2 (my system) and
4.8.3 (another system). On g++ 4.6.3, the Intel compiler 13.1 or clang 3.4 the
problem does not appear.
This is the version information from my system:
$ g++ --version
g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1) Failing compilation
command line: g++ -c arma_template_test.cpp -Wall -Wextra -std=c++11
-save-temps &> output.txt
Please see attached error messages in output.txt and attached prepocessed file
arma_template_test.ii. The error messages in output.txt are also repeated
directly in this bug report below.
Code arma_template_test.cpp:
#include <armadillo>
#include <iostream>
template<int param>
class Test {
public:
void compute() {
arma::mat matrix = arma::randu(10,10);
matrix = matrix + matrix.t();
arma::vec eigval;
arma::mat eigvec;
arma::eig_sym(eigval, eigvec, matrix);
arma::mat exp_matrix = eigvec * arma::diagmat(arma::exp(eigval)) *
arma::trans(eigvec);
exp_matrix.print(std::cout);
}
};
int main() {
Test<1> test;
test.compute();
return 0;
}
2) Successful compilation without warnings
command line: g++ -c arma_no_template_test.cpp -Wall -Wextra -std=c++11
-save-temps
Please see attached prepocessed file arma_no_template_test.ii
Code arma_no_template_test.cpp:
#include <armadillo>
#include <iostream>
class Test {
public:
void compute() {
arma::mat matrix = arma::randu(10,10);
matrix = matrix + matrix.t();
arma::vec eigval;
arma::mat eigvec;
arma::eig_sym(eigval, eigvec, matrix);
arma::mat exp_matrix = eigvec * arma::diagmat(arma::exp(eigval)) *
arma::trans(eigvec);
exp_matrix.print(std::cout);
}
};
int main() {
Test test;
test.compute();
return 0;
}
3) Error messages for failing compilation (output.txt):
In file included from /usr/include/armadillo:105:0,
from arma_template_test.cpp:1:
/usr/include/armadillo_bits/traits.hpp: In instantiation of ‘const bool
arma::is_Mat_fixed<arma::eOp<arma::Col<double>, arma::eop_exp> >::value’:
/usr/include/armadillo_bits/diagmat_proxy.hpp:415:7: required from ‘class
arma::diagmat_proxy_check<arma::eOp<arma::Col<double>, arma::eop_exp> >’
/usr/include/armadillo_bits/glue_times_meat.hpp:851:44: required from ‘static
void arma::glue_times_diag::apply(arma::Mat<typename T1::elem_type>&, const
arma::Glue<T1, T2, arma::glue_times_diag>&) [with T1 = arma::Mat<double>; T2 =
arma::Op<arma::eOp<arma::Col<double>, arma::eop_exp>, arma::op_diagmat>;
typename T1::elem_type = double]’
/usr/include/armadillo_bits/Mat_meat.hpp:4377:28: required from
‘arma::Mat<eT>::Mat(const arma::Glue<T1, T2, glue_type>&) [with T1 =
arma::Mat<double>; T2 = arma::Op<arma::eOp<arma::Col<double>, arma::eop_exp>,
arma::op_diagmat>; glue_type = arma::glue_times_diag; eT = double]’
/usr/include/armadillo_bits/glue_times_meat.hpp:82:25: required from ‘static
void arma::glue_times_redirect2_helper<true>::apply(arma::Mat<typename
T1::elem_type>&, const arma::Glue<T1, T2, arma::glue_times>&) [with T1 =
arma::Glue<arma::Mat<double>, arma::Op<arma::eOp<arma::Col<double>,
arma::eop_exp>, arma::op_diagmat>, arma::glue_times_diag>; T2 =
arma::Op<arma::Mat<double>, arma::op_htrans>; typename T1::elem_type = double]’
/usr/include/armadillo_bits/glue_times_meat.hpp:318:81: required from ‘static
void arma::glue_times_redirect<2u>::apply(arma::Mat<typename T1::elem_type>&,
const arma::Glue<T1, T2, arma::glue_times>&) [with T1 =
arma::Glue<arma::Mat<double>, arma::Op<arma::eOp<arma::Col<double>,
arma::eop_exp>, arma::op_diagmat>, arma::glue_times_diag>; T2 =
arma::Op<arma::Mat<double>, arma::op_htrans>; typename T1::elem_type = double]’
/usr/include/armadillo_bits/glue_times_meat.hpp:412:43: required from ‘static
void arma::glue_times::apply(arma::Mat<typename T1::elem_type>&, const
arma::Glue<T1, T2, arma::glue_times>&) [with T1 = arma::Glue<arma::Mat<double>,
arma::Op<arma::eOp<arma::Col<double>, arma::eop_exp>, arma::op_diagmat>,
arma::glue_times_diag>; T2 = arma::Op<arma::Mat<double>, arma::op_htrans>;
typename T1::elem_type = double]’
/usr/include/armadillo_bits/Mat_meat.hpp:4377:28: required from
‘arma::Mat<eT>::Mat(const arma::Glue<T1, T2, glue_type>&) [with T1 =
arma::Glue<arma::Mat<double>, arma::Op<arma::eOp<arma::Col<double>,
arma::eop_exp>, arma::op_diagmat>, arma::glue_times_diag>; T2 =
arma::Op<arma::Mat<double>, arma::op_htrans>; glue_type = arma::glue_times; eT
= double]’
arma_template_test.cpp:14:94: required from ‘void Test<param>::compute()
[with int param = 1]’
arma_template_test.cpp:22:18: required from here
/usr/include/armadillo_bits/traits.hpp:67:23: error: non-constant in-class
initialization invalid for static member
‘arma::is_Mat_fixed<arma::eOp<arma::Col<double>, arma::eop_exp> >::value’
{ static const bool value = ( is_Mat_fixed_only<T>::value ||
is_Row_fixed_only<T>::value || is_Col_fixed_only<T>::value ); };
^
/usr/include/armadillo_bits/traits.hpp:67:23: error: (an out of class
initialization is required)
/usr/include/armadillo_bits/traits.hpp:67:23: error:
‘arma::is_Mat_fixed<arma::eOp<arma::Col<double>, arma::eop_exp> >::value’
cannot be initialized by a non-constant expression when being declared
In file included from /usr/include/armadillo:301:0,
from arma_template_test.cpp:1:
/usr/include/armadillo_bits/diagmat_proxy.hpp: In instantiation of ‘class
arma::diagmat_proxy_check<arma::eOp<arma::Col<double>, arma::eop_exp> >’:
/usr/include/armadillo_bits/glue_times_meat.hpp:851:44: required from ‘static
void arma::glue_times_diag::apply(arma::Mat<typename T1::elem_type>&, const
arma::Glue<T1, T2, arma::glue_times_diag>&) [with T1 = arma::Mat<double>; T2 =
arma::Op<arma::eOp<arma::Col<double>, arma::eop_exp>, arma::op_diagmat>;
typename T1::elem_type = double]’
/usr/include/armadillo_bits/Mat_meat.hpp:4377:28: required from
‘arma::Mat<eT>::Mat(const arma::Glue<T1, T2, glue_type>&) [with T1 =
arma::Mat<double>; T2 = arma::Op<arma::eOp<arma::Col<double>, arma::eop_exp>,
arma::op_diagmat>; glue_type = arma::glue_times_diag; eT = double]’
/usr/include/armadillo_bits/glue_times_meat.hpp:82:25: required from ‘static
void arma::glue_times_redirect2_helper<true>::apply(arma::Mat<typename
T1::elem_type>&, const arma::Glue<T1, T2, arma::glue_times>&) [with T1 =
arma::Glue<arma::Mat<double>, arma::Op<arma::eOp<arma::Col<double>,
arma::eop_exp>, arma::op_diagmat>, arma::glue_times_diag>; T2 =
arma::Op<arma::Mat<double>, arma::op_htrans>; typename T1::elem_type = double]’
/usr/include/armadillo_bits/glue_times_meat.hpp:318:81: required from ‘static
void arma::glue_times_redirect<2u>::apply(arma::Mat<typename T1::elem_type>&,
const arma::Glue<T1, T2, arma::glue_times>&) [with T1 =
arma::Glue<arma::Mat<double>, arma::Op<arma::eOp<arma::Col<double>,
arma::eop_exp>, arma::op_diagmat>, arma::glue_times_diag>; T2 =
arma::Op<arma::Mat<double>, arma::op_htrans>; typename T1::elem_type = double]’
/usr/include/armadillo_bits/glue_times_meat.hpp:412:43: required from ‘static
void arma::glue_times::apply(arma::Mat<typename T1::elem_type>&, const
arma::Glue<T1, T2, arma::glue_times>&) [with T1 = arma::Glue<arma::Mat<double>,
arma::Op<arma::eOp<arma::Col<double>, arma::eop_exp>, arma::op_diagmat>,
arma::glue_times_diag>; T2 = arma::Op<arma::Mat<double>, arma::op_htrans>;
typename T1::elem_type = double]’
/usr/include/armadillo_bits/Mat_meat.hpp:4377:28: required from
‘arma::Mat<eT>::Mat(const arma::Glue<T1, T2, glue_type>&) [with T1 =
arma::Glue<arma::Mat<double>, arma::Op<arma::eOp<arma::Col<double>,
arma::eop_exp>, arma::op_diagmat>, arma::glue_times_diag>; T2 =
arma::Op<arma::Mat<double>, arma::op_htrans>; glue_type = arma::glue_times; eT
= double]’
arma_template_test.cpp:14:94: required from ‘void Test<param>::compute()
[with int param = 1]’
arma_template_test.cpp:22:18: required from here
/usr/include/armadillo_bits/diagmat_proxy.hpp:415:7: error: the value of
‘arma::is_Col_fixed_only<arma::eOp<arma::Col<double>, arma::eop_exp> >::value’
is not usable in a constant expression
class diagmat_proxy_check : public diagmat_proxy_check_redirect<T1,
is_Mat_fixed<T1>::value >::result
^
In file included from /usr/include/armadillo:105:0,
from arma_template_test.cpp:1:
/usr/include/armadillo_bits/traits.hpp:60:21: note:
‘arma::is_Col_fixed_only<arma::eOp<arma::Col<double>, arma::eop_exp> >::value’
was not initialized with a constant expression
static const bool value = ( sizeof(check<T>(0)) == sizeof(yes) );
^
In file included from /usr/include/armadillo:301:0,
from arma_template_test.cpp:1:
/usr/include/armadillo_bits/diagmat_proxy.hpp:415:7: note: in template argument
for type ‘bool’
class diagmat_proxy_check : public diagmat_proxy_check_redirect<T1,
is_Mat_fixed<T1>::value >::result
^
In file included from /usr/include/armadillo:564:0,
from arma_template_test.cpp:1:
/usr/include/armadillo_bits/glue_times_meat.hpp: In instantiation of ‘static
void arma::glue_times_diag::apply(arma::Mat<typename T1::elem_type>&, const
arma::Glue<T1, T2, arma::glue_times_diag>&) [with T1 = arma::Mat<double>; T2 =
arma::Op<arma::eOp<arma::Col<double>, arma::eop_exp>, arma::op_diagmat>;
typename T1::elem_type = double]’:
/usr/include/armadillo_bits/Mat_meat.hpp:4377:28: required from
‘arma::Mat<eT>::Mat(const arma::Glue<T1, T2, glue_type>&) [with T1 =
arma::Mat<double>; T2 = arma::Op<arma::eOp<arma::Col<double>, arma::eop_exp>,
arma::op_diagmat>; glue_type = arma::glue_times_diag; eT = double]’
/usr/include/armadillo_bits/glue_times_meat.hpp:82:25: required from ‘static
void arma::glue_times_redirect2_helper<true>::apply(arma::Mat<typename
T1::elem_type>&, const arma::Glue<T1, T2, arma::glue_times>&) [with T1 =
arma::Glue<arma::Mat<double>, arma::Op<arma::eOp<arma::Col<double>,
arma::eop_exp>, arma::op_diagmat>, arma::glue_times_diag>; T2 =
arma::Op<arma::Mat<double>, arma::op_htrans>; typename T1::elem_type = double]’
/usr/include/armadillo_bits/glue_times_meat.hpp:318:81: required from ‘static
void arma::glue_times_redirect<2u>::apply(arma::Mat<typename T1::elem_type>&,
const arma::Glue<T1, T2, arma::glue_times>&) [with T1 =
arma::Glue<arma::Mat<double>, arma::Op<arma::eOp<arma::Col<double>,
arma::eop_exp>, arma::op_diagmat>, arma::glue_times_diag>; T2 =
arma::Op<arma::Mat<double>, arma::op_htrans>; typename T1::elem_type = double]’
/usr/include/armadillo_bits/glue_times_meat.hpp:412:43: required from ‘static
void arma::glue_times::apply(arma::Mat<typename T1::elem_type>&, const
arma::Glue<T1, T2, arma::glue_times>&) [with T1 = arma::Glue<arma::Mat<double>,
arma::Op<arma::eOp<arma::Col<double>, arma::eop_exp>, arma::op_diagmat>,
arma::glue_times_diag>; T2 = arma::Op<arma::Mat<double>, arma::op_htrans>;
typename T1::elem_type = double]’
/usr/include/armadillo_bits/Mat_meat.hpp:4377:28: required from
‘arma::Mat<eT>::Mat(const arma::Glue<T1, T2, glue_type>&) [with T1 =
arma::Glue<arma::Mat<double>, arma::Op<arma::eOp<arma::Col<double>,
arma::eop_exp>, arma::op_diagmat>, arma::glue_times_diag>; T2 =
arma::Op<arma::Mat<double>, arma::op_htrans>; glue_type = arma::glue_times; eT
= double]’
arma_template_test.cpp:14:94: required from ‘void Test<param>::compute()
[with int param = 1]’
arma_template_test.cpp:22:18: required from here
/usr/include/armadillo_bits/glue_times_meat.hpp:855:30: error: ‘const class
arma::diagmat_proxy_check<arma::eOp<arma::Col<double>, arma::eop_exp> >’ has no
member named ‘n_elem’
const uword B_n_elem = B.n_elem;
^
/usr/include/armadillo_bits/glue_times_meat.hpp:863:23: error: no match for
‘operator[]’ (operand types are ‘const
arma::diagmat_proxy_check<arma::eOp<arma::Col<double>, arma::eop_exp> >’ and
‘arma::uword {aka unsigned int}’)
const eT val = B[col];
^
/usr/include/armadillo_bits/glue_times_meat.hpp:891:30: error: ‘const class
arma::diagmat_proxy_check<arma::eOp<arma::Col<double>, arma::eop_exp> >’ has no
member named ‘n_elem’
const uword B_n_elem = B.n_elem;
^
/usr/include/armadillo_bits/glue_times_meat.hpp:899:29: error: no match for
‘operator[]’ (operand types are ‘const
arma::diagmat_proxy_check<arma::eOp<arma::Col<double>, arma::eop_exp> >’ and
‘arma::uword {aka unsigned int}’)
out.at(i,i) = A[i] * B[i];
^
>From gcc-bugs-return-459197-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Aug 25 14:06:15 2014
Return-Path: <gcc-bugs-return-459197-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 9719 invoked by alias); 25 Aug 2014 14:06:14 -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 9691 invoked by uid 48); 25 Aug 2014 14:06:09 -0000
From: "conradsand.arma at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/62255] Introducing an unrelated template parameter causes compilation to fail
Date: Mon, 25 Aug 2014 14:06: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: 4.8.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: conradsand.arma at gmail dot com
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: cc
Message-ID: <bug-62255-4-c1DQLBda1P@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-62255-4@http.gcc.gnu.org/bugzilla/>
References: <bug-62255-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-08/txt/msg01694.txt.bz2
Content-length: 480
https://gcc.gnu.org/bugzilla/show_bug.cgi?idb255
Conrad <conradsand.arma at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |conradsand.arma at gmail dot com
--- Comment #1 from Conrad <conradsand.arma at gmail dot com> ---
Confirmed on g++ 4.8.3, Fedora 20, 64 bit.
gcc version 4.8.3 20140624 (Red Hat 4.8.3-1) (GCC)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/62255] Introducing an unrelated template parameter causes compilation to fail
2014-08-25 13:52 [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation m at maxgerlach dot de
@ 2014-08-25 14:15 ` conradsand.arma at gmail dot com
2014-08-26 9:32 ` m at maxgerlach dot de
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: conradsand.arma at gmail dot com @ 2014-08-25 14:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255
--- Comment #2 from Conrad <conradsand.arma at gmail dot com> ---
When the irrelevant template parameter is used (arma_template_test.ii), g++
thinks that "value" in the following code can't be determined at compile time:
template<typename T>
struct is_Col_fixed_only
{
typedef char yes[1];
typedef char no[2];
template<typename X> static yes& check(typename X::Col_fixed_type*);
template<typename> static no& check(...);
static const bool value = ( sizeof(check<T>(0)) == sizeof(yes) );
};
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/62255] Introducing an unrelated template parameter causes compilation to fail
2014-08-25 13:52 [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation m at maxgerlach dot de
2014-08-25 14:15 ` [Bug c++/62255] Introducing an unrelated template parameter causes compilation to fail conradsand.arma at gmail dot com
@ 2014-08-26 9:32 ` m at maxgerlach dot de
2014-08-26 9:33 ` m at maxgerlach dot de
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: m at maxgerlach dot de @ 2014-08-26 9:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255
--- Comment #3 from Max Gerlach <m at maxgerlach dot de> ---
Created attachment 33397
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33397&action=edit
Compiler error messages from g++ 4.9.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/62255] Introducing an unrelated template parameter causes compilation to fail
2014-08-25 13:52 [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation m at maxgerlach dot de
2014-08-25 14:15 ` [Bug c++/62255] Introducing an unrelated template parameter causes compilation to fail conradsand.arma at gmail dot com
2014-08-26 9:32 ` m at maxgerlach dot de
@ 2014-08-26 9:33 ` m at maxgerlach dot de
2014-08-26 13:26 ` m at maxgerlach dot de
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: m at maxgerlach dot de @ 2014-08-26 9:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255
--- Comment #4 from Max Gerlach <m at maxgerlach dot de> ---
The bug is still present on g++ 4.9.1.
$ g++-4.9 --version
g++-4.9 (Ubuntu 4.9.1-3ubuntu2~14.04.1) 4.9.1
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Output of
$ g++-4.9 -c arma_template_test.cpp -Wall -Wextra -std=c++11 &>
output-4.9.1.txt
has been attached.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/62255] Introducing an unrelated template parameter causes compilation to fail
2014-08-25 13:52 [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation m at maxgerlach dot de
` (2 preceding siblings ...)
2014-08-26 9:33 ` m at maxgerlach dot de
@ 2014-08-26 13:26 ` m at maxgerlach dot de
2014-09-05 15:06 ` [Bug c++/62255] [4.8/4.9 Regression] " jakub at gcc dot gnu.org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: m at maxgerlach dot de @ 2014-08-26 13:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255
Max Gerlach <m at maxgerlach dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |4.7.3
--- Comment #5 from Max Gerlach <m at maxgerlach dot de> ---
gcc 4.7.3 compiles the code without errors.
$ g++-4.7 --version
g++-4.7 (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/62255] [4.8/4.9 Regression] Introducing an unrelated template parameter causes compilation to fail
2014-08-25 13:52 [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation m at maxgerlach dot de
` (3 preceding siblings ...)
2014-08-26 13:26 ` m at maxgerlach dot de
@ 2014-09-05 15:06 ` jakub at gcc dot gnu.org
2014-09-06 0:05 ` jason at gcc dot gnu.org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-09-05 15:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255
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
Target Milestone|--- |4.8.4
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This started to be rejected with r197613 (one needs -std=c++11 -mfxsr to
compile it BTW). Whether it is valid or not I'll defer to the C++ folks.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/62255] [4.8/4.9 Regression] Introducing an unrelated template parameter causes compilation to fail
2014-08-25 13:52 [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation m at maxgerlach dot de
` (4 preceding siblings ...)
2014-09-05 15:06 ` [Bug c++/62255] [4.8/4.9 Regression] " jakub at gcc dot gnu.org
@ 2014-09-06 0:05 ` jason at gcc dot gnu.org
2014-09-06 3:45 ` jason at gcc dot gnu.org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2014-09-06 0:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255
--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> ---
The problem with this testcase is that in evaluating
arma::is_Mat_fixed_only<arma::eOp<arma::Col<double>, arma::eop_exp> >::value we
need to look up check<arma::eOp<arma::Col<double>, arma::eop_exp>>, which means
looking up arma::eOp<arma::Col<double>, arma::eop_exp>::Mat_fixed_type, which
means instantiating arma::eOp<arma::Col<double>, arma::eop_exp> if it isn't
already complete.
Which means instantiating arma::Base<double, arma::eOp<arma::Col<double>,
arma::eop_exp>>
Which means substituting into arma::Base_eval<elem_type, derived,
arma::is_Mat<derived>::value>
Which depends on arma::is_Mat_fixed_only<arma::eOp<arma::Col<double>,
arma::eop_exp> >::value, which is where we started.
So instantiating the decl ends up requiring its own definition, though the
actual value does not depend on itself, so we could probably allow it. The
loop would be avoided if arma::eOp<arma::Col<double>, arma::eop_exp> is
instantiated before we try to instantiate the value.
Here's a simpler testcase that doesn't happen to fail with GCC for some reason,
but does with clang:
template <class T> struct B;
template <bool b>
struct C { };
template <class T>
struct A: C<B<A<T>>::value>
{
typedef T Type;
};
template<class T>
struct B
{
template<typename X> static int check(typename X::Type*);
template<typename> static char check(...);
static const bool value = (sizeof(check<T>(0)) == sizeof(int));
};
int main()
{
return B<A<int>>::value;
}
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/62255] [4.8/4.9 Regression] Introducing an unrelated template parameter causes compilation to fail
2014-08-25 13:52 [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation m at maxgerlach dot de
` (5 preceding siblings ...)
2014-09-06 0:05 ` jason at gcc dot gnu.org
@ 2014-09-06 3:45 ` jason at gcc dot gnu.org
2014-09-06 16:37 ` jason at gcc dot gnu.org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2014-09-06 3:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255
--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
And here's a reduced testcase that GCC and EDG reject, but clang accepts.
template <typename T> struct Test {
template <typename X> static void check(typename X::Undefined *);
template <typename> static int &check(...);
static const int value = sizeof (check<T>());
};
template <int> struct Sink { };
template <typename T> struct Base : Sink<Test<T>::value> {};
template <typename T> class Derived : Base<Derived<T> > {};
int i[Test<Derived<int> >::value];
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/62255] [4.8/4.9 Regression] Introducing an unrelated template parameter causes compilation to fail
2014-08-25 13:52 [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation m at maxgerlach dot de
` (6 preceding siblings ...)
2014-09-06 3:45 ` jason at gcc dot gnu.org
@ 2014-09-06 16:37 ` jason at gcc dot gnu.org
2014-09-09 12:00 ` jason at gcc dot gnu.org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2014-09-06 16:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2014-09-06
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #9 from Jason Merrill <jason at gcc dot gnu.org> ---
And one rejected by all of GCC, Clang and EDG (but also accepted by 4.7):
template <typename T> struct Test {
template<typename X> static int check(typename X::Type*);
template<typename> static char check(...);
static const int value = sizeof(check<T>(0));
};
template <int> struct Sink { };
template <typename T> class Derived : Sink<Test<Derived<T> >::value> {};
Sink<Test<Derived<int> >::value> s;
If we somehow cause Derived<int> to be instantiated before the last line, such
as by declaring a Derived<int> variable, everything is fine. We only run into
trouble because it hasn't been.
r197613 caused this to start breaking because before that change we had briefly
been instantiating classes in more situations, but that caused its own
problems.
It's not clear to me that this needs to be ill-formed; the value is not
dependent on itself, it's just an accident of instantiation context. We could
decide to just handle this. I think I'll make that change and also bring it up
with the committee.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/62255] [4.8/4.9 Regression] Introducing an unrelated template parameter causes compilation to fail
2014-08-25 13:52 [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation m at maxgerlach dot de
` (7 preceding siblings ...)
2014-09-06 16:37 ` jason at gcc dot gnu.org
@ 2014-09-09 12:00 ` jason at gcc dot gnu.org
2014-12-10 13:02 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2014-09-09 12:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255
--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Tue Sep 9 11:59:45 2014
New Revision: 215062
URL: https://gcc.gnu.org/viewcvs?rev=215062&root=gcc&view=rev
Log:
PR c++/62255
* pt.c (instantiate_decl): Handle recursive instantiation of
static data member.
Added:
trunk/gcc/testsuite/g++.dg/template/recurse4.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/pt.c
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/62255] [4.8/4.9 Regression] Introducing an unrelated template parameter causes compilation to fail
2014-08-25 13:52 [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation m at maxgerlach dot de
` (8 preceding siblings ...)
2014-09-09 12:00 ` jason at gcc dot gnu.org
@ 2014-12-10 13:02 ` rguenth at gcc dot gnu.org
2014-12-19 13:29 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-12-10 13:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Priority|P3 |P2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/62255] [4.8/4.9 Regression] Introducing an unrelated template parameter causes compilation to fail
2014-08-25 13:52 [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation m at maxgerlach dot de
` (9 preceding siblings ...)
2014-12-10 13:02 ` rguenth at gcc dot gnu.org
@ 2014-12-19 13:29 ` jakub at gcc dot gnu.org
2015-02-26 7:34 ` jason at gcc dot gnu.org
2015-03-19 15:17 ` jason at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-19 13:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.8.4 |4.8.5
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.4 has been released.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/62255] [4.8/4.9 Regression] Introducing an unrelated template parameter causes compilation to fail
2014-08-25 13:52 [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation m at maxgerlach dot de
` (10 preceding siblings ...)
2014-12-19 13:29 ` jakub at gcc dot gnu.org
@ 2015-02-26 7:34 ` jason at gcc dot gnu.org
2015-03-19 15:17 ` jason at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2015-02-26 7:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255
--- Comment #12 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Thu Feb 26 02:43:58 2015
New Revision: 220997
URL: https://gcc.gnu.org/viewcvs?rev=220997&root=gcc&view=rev
Log:
PR c++/62255
* pt.c (instantiate_decl): Handle recursive instantiation of
static data member.
Added:
branches/gcc-4_9-branch/gcc/testsuite/g++.dg/template/recurse4.C
Modified:
branches/gcc-4_9-branch/gcc/cp/ChangeLog
branches/gcc-4_9-branch/gcc/cp/pt.c
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/62255] [4.8/4.9 Regression] Introducing an unrelated template parameter causes compilation to fail
2014-08-25 13:52 [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation m at maxgerlach dot de
` (11 preceding siblings ...)
2015-02-26 7:34 ` jason at gcc dot gnu.org
@ 2015-03-19 15:17 ` jason at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2015-03-19 15:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
Target Milestone|4.8.5 |4.9.3
--- Comment #13 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 4.9.3/5.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2015-03-19 14:33 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-25 13:52 [Bug c++/62255] New: Introducing an unrelated template parameter causes failed compilation m at maxgerlach dot de
2014-08-25 14:15 ` [Bug c++/62255] Introducing an unrelated template parameter causes compilation to fail conradsand.arma at gmail dot com
2014-08-26 9:32 ` m at maxgerlach dot de
2014-08-26 9:33 ` m at maxgerlach dot de
2014-08-26 13:26 ` m at maxgerlach dot de
2014-09-05 15:06 ` [Bug c++/62255] [4.8/4.9 Regression] " jakub at gcc dot gnu.org
2014-09-06 0:05 ` jason at gcc dot gnu.org
2014-09-06 3:45 ` jason at gcc dot gnu.org
2014-09-06 16:37 ` jason at gcc dot gnu.org
2014-09-09 12:00 ` jason at gcc dot gnu.org
2014-12-10 13:02 ` rguenth at gcc dot gnu.org
2014-12-19 13:29 ` jakub at gcc dot gnu.org
2015-02-26 7:34 ` jason at gcc dot gnu.org
2015-03-19 15:17 ` 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).