public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/9278: dependent type in conversion operator bug
@ 2003-01-12 23:52 bangerth
  0 siblings, 0 replies; 7+ messages in thread
From: bangerth @ 2003-01-12 23:52 UTC (permalink / raw)
  To: dave, gcc-bugs, gcc-prs, nobody

Synopsis: dependent type in conversion operator bug

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Sun Jan 12 15:52:22 2003
State-Changed-Why:
    Confirmed. I have no clue what the standard says, but an
    indication that gcc is actually wrong may be given by the
    fact that the code actually compiles when struct voidify
    is having its template removed.
    
    W.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9278


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

* Re: c++/9278: dependent type in conversion operator bug
@ 2003-01-14  2:36 David Abrahams
  0 siblings, 0 replies; 7+ messages in thread
From: David Abrahams @ 2003-01-14  2:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/9278; it has been noted by GNATS.

From: David Abrahams <dave@boost-consulting.com>
To: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
Cc: "Joseph S. Myers" <jsm28@cam.ac.uk>,  <gcc-bugs@gcc.gnu.org>,
	  <gcc-gnats@gcc.gnu.org>
Subject: Re: c++/9278: dependent type in conversion operator bug
Date: Mon, 13 Jan 2003 21:25:30 -0500

 Wolfgang Bangerth <bangerth@ticam.utexas.edu> writes:
 
 >> > Indeed a very obscure feature. (Although, I must admit that, I desperately 
 >> > needed something like that not too long ago and had to invent various 
 >> > template metaprogramming hoops to work around...)
 >> 
 >> I needed exactly that yesterday, which is why it came up ;-)
 >> Using SFINAE to rule out certain conversions was my game, but it
 >> didn't fly :(
 >
 > SFINAE???
 
 "Substitution Failure Is Not An Error"
 
 basically you can take an overload out of the overload set by causing
 an invalid type computation in one of the arguments or return type:
 
 template <bool = true, class T>
 struct enable_if { typedef T type; };
 template <class T>
 struct enable_if<false,T> {};
 
 // Define addition for all enums, but only for enums
 template <class T>
 typename enable_if<boost::is_enum<T>::value, T>::type
 operator+(T x, T y) { return T(x+y); }
 
 > In my case, I wanted to make things more uniform in Functor classes: when 
 > you call a function, it either returns a value, or void. So this does not
 > go together
 >   RETTYPE ret_val = function(args)
 > if RETTYPE==void. What an annoying difference, and how convenient would it 
 > be if there were "void variables", i.e. objects to which you can assign 
 > the result of a void expression :-)
 
 Oh.  But you are allowed to write "return function(args);" even if
 function returns void.
 
 > Some template trickery and specilization can get one around this, however.
 
 Been there, done that.
 
 -- 
                        David Abrahams
    dave@boost-consulting.com * http://www.boost-consulting.com
 Boost support, enhancements, training, and commercial distribution
 


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

* Re: c++/9278: dependent type in conversion operator bug
@ 2003-01-14  0:36 Wolfgang Bangerth
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Bangerth @ 2003-01-14  0:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/9278; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: David Abrahams <dave@boost-consulting.com>
Cc: "Joseph S. Myers" <jsm28@cam.ac.uk>, <gcc-bugs@gcc.gnu.org>,
   <gcc-gnats@gcc.gnu.org>
Subject: Re: c++/9278: dependent type in conversion operator bug
Date: Mon, 13 Jan 2003 18:27:36 -0600 (CST)

 > > Indeed a very obscure feature. (Although, I must admit that, I desperately 
 > > needed something like that not too long ago and had to invent various 
 > > template metaprogramming hoops to work around...)
 > 
 > I needed exactly that yesterday, which is why it came up ;-)
 > Using SFINAE to rule out certain conversions was my game, but it
 > didn't fly :(
 
 SFINAE???
 
 In my case, I wanted to make things more uniform in Functor classes: when 
 you call a function, it either returns a value, or void. So this does not
 go together
   RETTYPE ret_val = function(args)
 if RETTYPE==void. What an annoying difference, and how convenient would it 
 be if there were "void variables", i.e. objects to which you can assign 
 the result of a void expression :-)
 
 Some template trickery and specilization can get one around this, however.
 
 W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth             email:            bangerth@ticam.utexas.edu
                               www: http://www.ticam.utexas.edu/~bangerth/
 
 


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

* Re: c++/9278: dependent type in conversion operator bug
@ 2003-01-14  0:26 David Abrahams
  0 siblings, 0 replies; 7+ messages in thread
From: David Abrahams @ 2003-01-14  0:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/9278; it has been noted by GNATS.

From: David Abrahams <dave@boost-consulting.com>
To: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
Cc: "Joseph S. Myers" <jsm28@cam.ac.uk>,  <gcc-bugs@gcc.gnu.org>,
	  <gcc-gnats@gcc.gnu.org>
Subject: Re: c++/9278: dependent type in conversion operator bug
Date: Mon, 13 Jan 2003 19:14:07 -0500

 Wolfgang Bangerth <bangerth@ticam.utexas.edu> writes:
 
 >> >   http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#18
 >> 
 >> Another obscure difference between C and C++.  In C you can use a typedef
 >> to void here <http://std.dkuug.dk/JTC1/SC22/WG14/www/docs/dr_157.html>.
 >
 > Thanks for pointing this out. This makes it very clear that the code is 
 > illegal and should not compile.
 >
 > Indeed a very obscure feature. (Although, I must admit that, I desperately 
 > needed something like that not too long ago and had to invent various 
 > template metaprogramming hoops to work around...)
 
 I needed exactly that yesterday, which is why it came up ;-)
 Using SFINAE to rule out certain conversions was my game, but it
 didn't fly :(
 
 -- 
                        David Abrahams
    dave@boost-consulting.com * http://www.boost-consulting.com
 Boost support, enhancements, training, and commercial distribution
 


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

* Re: c++/9278: dependent type in conversion operator bug
@ 2003-01-13 23:06 Wolfgang Bangerth
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Bangerth @ 2003-01-13 23:06 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/9278; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: "Joseph S. Myers" <jsm28@cam.ac.uk>
Cc: David Abrahams <dave@boost-consulting.com>, <gcc-bugs@gcc.gnu.org>,
   <gcc-gnats@gcc.gnu.org>
Subject: Re: c++/9278: dependent type in conversion operator bug
Date: Mon, 13 Jan 2003 17:03:34 -0600 (CST)

 > >   http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#18
 > 
 > Another obscure difference between C and C++.  In C you can use a typedef
 > to void here <http://std.dkuug.dk/JTC1/SC22/WG14/www/docs/dr_157.html>.
 
 Thanks for pointing this out. This makes it very clear that the code is 
 illegal and should not compile.
 
 Indeed a very obscure feature. (Although, I must admit that, I desperately 
 needed something like that not too long ago and had to invent various 
 template metaprogramming hoops to work around...)
 
 Regards
   Wolfgang
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth             email:            bangerth@ticam.utexas.edu
                               www: http://www.ticam.utexas.edu/~bangerth/
 
 


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

* Re: c++/9278: dependent type in conversion operator bug
@ 2003-01-13 22:56 Joseph S. Myers
  0 siblings, 0 replies; 7+ messages in thread
From: Joseph S. Myers @ 2003-01-13 22:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/9278; it has been noted by GNATS.

From: "Joseph S. Myers" <jsm28@cam.ac.uk>
To: David Abrahams <dave@boost-consulting.com>
Cc: <bangerth@dealii.org>,  <gcc-bugs@gcc.gnu.org>,  <gcc-gnats@gcc.gnu.org>
Subject: Re: c++/9278: dependent type in conversion operator bug
Date: Mon, 13 Jan 2003 22:47:47 +0000 (GMT)

 On Sun, 12 Jan 2003, David Abrahams wrote:
 
 >   http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#18
 
 Another obscure difference between C and C++.  In C you can use a typedef
 to void here <http://std.dkuug.dk/JTC1/SC22/WG14/www/docs/dr_157.html>.
 
 -- 
 Joseph S. Myers
 jsm28@cam.ac.uk
 


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

* c++/9278: dependent type in conversion operator bug
@ 2003-01-12  3:56 dave
  0 siblings, 0 replies; 7+ messages in thread
From: dave @ 2003-01-12  3:56 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9278
>Category:       c++
>Synopsis:       dependent type in conversion operator bug
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 11 19:56:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     dave@boost-consulting.com
>Release:        gcc-3.2
>Organization:
>Environment:
cygwin
>Description:
This fails to compile; I don't think it should.
Trust me, there is a use case for this sort of thing! ;-)
>How-To-Repeat:
# include <iostream>

// metafunction always returning void
template <class T> struct voidify { typedef void type; };

template <class T> struct Y {};

struct X
{
    template <class T>
    operator Y<T> (typename voidify<T>::type) const { return Y<T>(); }
};

int main()
{
    X x();
    return 0;
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2003-01-14  2:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-12 23:52 c++/9278: dependent type in conversion operator bug bangerth
  -- strict thread matches above, loose matches on Subject: below --
2003-01-14  2:36 David Abrahams
2003-01-14  0:36 Wolfgang Bangerth
2003-01-14  0:26 David Abrahams
2003-01-13 23:06 Wolfgang Bangerth
2003-01-13 22:56 Joseph S. Myers
2003-01-12  3:56 dave

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