public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49470] New: no matching constructor for initialization errors not detected in g++
@ 2011-06-20 3:06 howarth at nitro dot med.uc.edu
2011-06-20 3:12 ` [Bug c++/49470] " howarth at nitro dot med.uc.edu
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: howarth at nitro dot med.uc.edu @ 2011-06-20 3:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49470
Summary: no matching constructor for initialization errors not
detected in g++
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: howarth@nitro.med.uc.edu
Currently g++ doesn't warn or error on invalid code such as...
template <class T> class Array1D {
Array1D(int n, T *a);
};
template<typename T>
struct A {
Array1D<int> x;
A() : x(1, (const int*)0) {}
};
for which clang++ produces the error...
[MacPro:~] howarth% clang++ -c invalid.cc
invalid.cc:7:9: error: no matching constructor for initialization of
'Array1D<int>'
A() : x(1, (const int*)0) {}
^ ~~~~~~~~~~~~~~~~
invalid.cc:2:3: note: candidate constructor not viable: 2nd argument ('const
int *') would lose const qualifier
Array1D(int n, T *a);
^
invalid.cc:1:26: note: candidate constructor (the implicit copy constructor)
not viable: requires 1 argument, but 2 were provided
template <class T> class Array1D {
^
1 error generated.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/49470] no matching constructor for initialization errors not detected in g++
2011-06-20 3:06 [Bug c++/49470] New: no matching constructor for initialization errors not detected in g++ howarth at nitro dot med.uc.edu
@ 2011-06-20 3:12 ` howarth at nitro dot med.uc.edu
2011-06-20 10:06 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: howarth at nitro dot med.uc.edu @ 2011-06-20 3:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49470
--- Comment #1 from Jack Howarth <howarth at nitro dot med.uc.edu> 2011-06-20 03:12:23 UTC ---
This test case originates from http://llvm.org/bugs/show_bug.cgi?id=9627.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/49470] no matching constructor for initialization errors not detected in g++
2011-06-20 3:06 [Bug c++/49470] New: no matching constructor for initialization errors not detected in g++ howarth at nitro dot med.uc.edu
2011-06-20 3:12 ` [Bug c++/49470] " howarth at nitro dot med.uc.edu
@ 2011-06-20 10:06 ` redi at gcc dot gnu.org
2011-06-20 10:27 ` redi at gcc dot gnu.org
2011-06-22 20:44 ` [Bug c++/49470] optional diagnostic not given for invalid mem-initializer in uninstantiated template jason at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2011-06-20 10:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49470
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-06-20 10:06:13 UTC ---
If you instantiate the template you get an error.
There are LOTS of things clang diagnoses in uninstantiated templates that g++
doesn't
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/49470] no matching constructor for initialization errors not detected in g++
2011-06-20 3:06 [Bug c++/49470] New: no matching constructor for initialization errors not detected in g++ howarth at nitro dot med.uc.edu
2011-06-20 3:12 ` [Bug c++/49470] " howarth at nitro dot med.uc.edu
2011-06-20 10:06 ` redi at gcc dot gnu.org
@ 2011-06-20 10:27 ` redi at gcc dot gnu.org
2011-06-22 20:44 ` [Bug c++/49470] optional diagnostic not given for invalid mem-initializer in uninstantiated template jason at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2011-06-20 10:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49470
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Severity|normal |enhancement
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-06-20 10:26:56 UTC ---
The summary isn't very relevant, the problem has nothing to do with
constructors, it's just that g++ doesn't check before instantiation whether no
valid specialization can be formed for a template.
14.6 [temp.res] p7:
If no valid specialization can be generated for a template definition, and that
template is not instantiated, the template definition is ill-formed, no
diagnostic required. ... [ Note: If a template is instantiated, errors will be
diagnosed according to the other rules in this Standard. Exactly when these
errors are diagnosed is a quality of implementation issue. —end note ]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/49470] optional diagnostic not given for invalid mem-initializer in uninstantiated template
2011-06-20 3:06 [Bug c++/49470] New: no matching constructor for initialization errors not detected in g++ howarth at nitro dot med.uc.edu
` (2 preceding siblings ...)
2011-06-20 10:27 ` redi at gcc dot gnu.org
@ 2011-06-22 20:44 ` jason at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-22 20:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49470
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.06.22 20:44:17
Summary|no matching constructor for |optional diagnostic not
|initialization errors not |given for invalid
|detected in g++ |mem-initializer in
| |uninstantiated template
Ever Confirmed|0 |1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-06-22 20:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-20 3:06 [Bug c++/49470] New: no matching constructor for initialization errors not detected in g++ howarth at nitro dot med.uc.edu
2011-06-20 3:12 ` [Bug c++/49470] " howarth at nitro dot med.uc.edu
2011-06-20 10:06 ` redi at gcc dot gnu.org
2011-06-20 10:27 ` redi at gcc dot gnu.org
2011-06-22 20:44 ` [Bug c++/49470] optional diagnostic not given for invalid mem-initializer in uninstantiated template 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).