public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/19404] New: error: 'QSizePolicy::<anonymous enum>' uses anonymous type
@ 2005-01-12 18:46 Woebbeking at web dot de
  2005-01-12 18:53 ` [Bug c++/19404] [4.0 Regression] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Woebbeking at web dot de @ 2005-01-12 18:46 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1221 bytes --]

Hi, 
 
the following Code doesn't compile: 
 
 
class Base; 
 
 
template<typename Type> 
inline 
Base& 
operator<<(Base& rConfiguration, 
           Type const& rType) 
{ 
    return rConfiguration; 
} 
 
 
template<typename Type> 
inline 
Base const& 
operator>>(Base const& rConfiguration, 
           Type& rType) 
{ 
    return rConfiguration; 
} 
 
 
struct QSizePolicy 
{ 
    enum { HSize = 6, HMask = 0x3f, VMask = HMask << HSize }; 
 
    enum SizeType { Fixed = 0 }; 
 
    SizeType verData() const { return (SizeType)( (data & VMask) >> HSize ); } 
 
    void setVerData( SizeType d ) { data = (unsigned int)(data & ~(HMask << 
HSize)) | 
        (d << HSize); } 
 
    unsigned int data; 
}; 
 
It compiles with g++ < 4.0. 
 
 
Cheers, 
André

-- 
           Summary: error: 'QSizePolicy::<anonymous enum>' uses anonymous
                    type
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Woebbeking at web dot de
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/19404] [4.0 Regression] error: 'QSizePolicy::<anonymous enum>' uses anonymous type
  2005-01-12 18:46 [Bug c++/19404] New: error: 'QSizePolicy::<anonymous enum>' uses anonymous type Woebbeking at web dot de
@ 2005-01-12 18:53 ` pinskia at gcc dot gnu dot org
  2005-01-12 20:35 ` [Bug c++/19404] [4.0 Regression] anonymous types and templates and rejecting valid code pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-12 18:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-12 18:53 -------
Confirmed, reduced testcase:
class Base; 
template<typename Type> 
inline  Base const& operator>>(Base const& rConfiguration, Type& rType) ;
enum { HSize = 6, HMask = 0x3f, VMask = HMask << HSize }; 
int verData(unsigned int data){ return (int)( (data & VMask) >> HSize ); } 

Note it start failing after "2004-12-11".

This is valid code we should reject the template as it does not fit with the arguments.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |rejects-valid
   Last reconfirmed|0000-00-00 00:00:00         |2005-01-12 18:53:44
               date|                            |
            Summary|error:                      |[4.0 Regression] error:
                   |'QSizePolicy::<anonymous    |'QSizePolicy::<anonymous
                   |enum>' uses anonymous type  |enum>' uses anonymous type
   Target Milestone|---                         |4.0.0


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


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

* [Bug c++/19404] [4.0 Regression] anonymous types and templates and rejecting valid code
  2005-01-12 18:46 [Bug c++/19404] New: error: 'QSizePolicy::<anonymous enum>' uses anonymous type Woebbeking at web dot de
  2005-01-12 18:53 ` [Bug c++/19404] [4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2005-01-12 20:35 ` pinskia at gcc dot gnu dot org
  2005-01-31  6:22 ` mmitchel at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-12 20:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-12 20:35 -------
The only patch which makes sense (as it is not really that bogus really as shown in this example):
        PR c++/17413
        * pt.c (check_instantiated_args): Remove bogus SFINAE code.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org, mmitchel at gcc dot gnu
                   |                            |dot org


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


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

* [Bug c++/19404] [4.0 Regression] anonymous types and templates and rejecting valid code
  2005-01-12 18:46 [Bug c++/19404] New: error: 'QSizePolicy::<anonymous enum>' uses anonymous type Woebbeking at web dot de
  2005-01-12 18:53 ` [Bug c++/19404] [4.0 Regression] " pinskia at gcc dot gnu dot org
  2005-01-12 20:35 ` [Bug c++/19404] [4.0 Regression] anonymous types and templates and rejecting valid code pinskia at gcc dot gnu dot org
@ 2005-01-31  6:22 ` mmitchel at gcc dot gnu dot org
  2005-04-08 14:36 ` lars at trolltech dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-01-31  6:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2005-01-31 06:22 -------
This code is invalid.  The use of ">>" requires the instantiation of the
declaration of the overloaded "operator>>", but that instantiation fails because
one of the template argument is anonymous.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug c++/19404] [4.0 Regression] anonymous types and templates and rejecting valid code
  2005-01-12 18:46 [Bug c++/19404] New: error: 'QSizePolicy::<anonymous enum>' uses anonymous type Woebbeking at web dot de
                   ` (2 preceding siblings ...)
  2005-01-31  6:22 ` mmitchel at gcc dot gnu dot org
@ 2005-04-08 14:36 ` lars at trolltech dot com
  2005-04-08 15:34 ` mark at codesourcery dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: lars at trolltech dot com @ 2005-04-08 14:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From lars at trolltech dot com  2005-04-08 14:36 -------
Hi Mark, 
 
(In reply to comment #3) 
> This code is invalid.  The use of ">>" requires the instantiation of the 
> declaration of the overloaded "operator>>", but that instantiation fails 
because 
> one of the template argument is anonymous. 
 
I don't see why the code is invalid. If you leave out the forward declaration 
of the template operator everything compiles fine, as the values in the 
anonymous enum get cast to integers, and the builtin operator>>(int, int) 
applies. 
 
So this compiles just fine (and to the correct code as far as I can tell): 
enum { HSize = 6, HMask = 0x3f, VMask = HMask << HSize };  
int verData(unsigned int data){ return (int)( (data & VMask) >> HSize ); }  
 
while this doesn't: 
 
class Base;  
template<typename Type>  
inline  Base const& operator>>(Base const& rConfiguration, Type& rType) ; 
enum { HSize = 6, HMask = 0x3f, VMask = HMask << HSize };  
int verData(unsigned int data){ return (int)( (data & VMask) >> HSize ); }  
 
The types in the forward declaration have no connection whatsoever with the 
values in the anonymous union, so the template should not apply. 
 
Lars 
 

-- 


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


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

* [Bug c++/19404] [4.0 Regression] anonymous types and templates and rejecting valid code
  2005-01-12 18:46 [Bug c++/19404] New: error: 'QSizePolicy::<anonymous enum>' uses anonymous type Woebbeking at web dot de
                   ` (3 preceding siblings ...)
  2005-04-08 14:36 ` lars at trolltech dot com
@ 2005-04-08 15:34 ` mark at codesourcery dot com
  2005-04-08 16:35 ` lars at trolltech dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mark at codesourcery dot com @ 2005-04-08 15:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mark at codesourcery dot com  2005-04-08 15:34 -------
Subject: Re:  [4.0 Regression] anonymous types and templates
 and rejecting valid code

lars at trolltech dot com wrote:
> ------- Additional Comments From lars at trolltech dot com  2005-04-08 14:36 -------
> Hi Mark, 
>  
> (In reply to comment #3) 
> 
>>This code is invalid.  The use of ">>" requires the instantiation of the 
>>declaration of the overloaded "operator>>", but that instantiation fails 
> 
> because 
> 
>>one of the template argument is anonymous. 
> 
>  
> I don't see why the code is invalid. If you leave out the forward declaration 
> of the template operator everything compiles fine, as the values in the 
> anonymous enum get cast to integers, and the builtin operator>>(int, int) 
> applies. 

Lars --

As I said earlier in the thread, there is now an open DR about this 
issue.  So, it might be resolved either way, eventually.

But, what the standard says at present is that you do overload 
resolution on both operators.  That requires that you instantiate their 
declarations, and the instantiation of the one using anonymous enums is 
invalid.  There's nothing in the standard that says that you discard 
instantiations that don't work -- except in cases of SFINAE.  And SFINAE 
does not let you ignore all errors, as some people think; it's a very 
specific set.



-- 


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


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

* [Bug c++/19404] [4.0 Regression] anonymous types and templates and rejecting valid code
  2005-01-12 18:46 [Bug c++/19404] New: error: 'QSizePolicy::<anonymous enum>' uses anonymous type Woebbeking at web dot de
                   ` (4 preceding siblings ...)
  2005-04-08 15:34 ` mark at codesourcery dot com
@ 2005-04-08 16:35 ` lars at trolltech dot com
  2005-04-27  9:15 ` pcarlini at suse dot de
  2005-05-06 20:16 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: lars at trolltech dot com @ 2005-04-08 16:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From lars at trolltech dot com  2005-04-08 16:35 -------
Subject: Re:  [4.0 Regression] anonymous types and templates and rejecting valid code

On Friday 08 April 2005 17:34, mark at codesourcery dot com wrote:
> ------- Additional Comments From mark at codesourcery dot com  2005-04-08
> 15:34 ------- Subject: Re:  [4.0 Regression] anonymous types and templates
>  and rejecting valid code
>
> lars at trolltech dot com wrote:
> > ------- Additional Comments From lars at trolltech dot com  2005-04-08
> > 14:36 ------- Hi Mark,
> >
> > (In reply to comment #3)
> >
> >>This code is invalid.  The use of ">>" requires the instantiation of the
> >>declaration of the overloaded "operator>>", but that instantiation fails
> >
> > because
> >
> >>one of the template argument is anonymous.
> >
> > I don't see why the code is invalid. If you leave out the forward
> > declaration of the template operator everything compiles fine, as the
> > values in the anonymous enum get cast to integers, and the builtin
> > operator>>(int, int) applies.
>
> Lars --
>
> As I said earlier in the thread, there is now an open DR about this
> issue.  So, it might be resolved either way, eventually.

Sorry, I didn't see the connection clearly. I was just wondering as we got a 
few bug reports about compile failures using Qt with gcc 4.

> But, what the standard says at present is that you do overload
> resolution on both operators.  That requires that you instantiate their
> declarations, and the instantiation of the one using anonymous enums is
> invalid.  There's nothing in the standard that says that you discard
> instantiations that don't work -- except in cases of SFINAE.  And SFINAE
> does not let you ignore all errors, as some people think; it's a very
> specific set.

I haven't read the standard to that level I have to admit :)

But if this invalid instantiation can't be ignored it seems to mean to me that 
one can not use any anonymous enum in C++ (better in a C++ header), as you 
would get compile errors as soon as someone uses a template to overload an 
operator that happens to be used together with values in the enum.

Cheers,
Lars


-- 


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


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

* [Bug c++/19404] [4.0 Regression] anonymous types and templates and rejecting valid code
  2005-01-12 18:46 [Bug c++/19404] New: error: 'QSizePolicy::<anonymous enum>' uses anonymous type Woebbeking at web dot de
                   ` (5 preceding siblings ...)
  2005-04-08 16:35 ` lars at trolltech dot com
@ 2005-04-27  9:15 ` pcarlini at suse dot de
  2005-05-06 20:16 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2005-04-27  9:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2005-04-27 09:15 -------
*** Bug 21244 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dominik dot strasser at
                   |                            |infineon dot com


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


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

* [Bug c++/19404] [4.0 Regression] anonymous types and templates and rejecting valid code
  2005-01-12 18:46 [Bug c++/19404] New: error: 'QSizePolicy::<anonymous enum>' uses anonymous type Woebbeking at web dot de
                   ` (6 preceding siblings ...)
  2005-04-27  9:15 ` pcarlini at suse dot de
@ 2005-05-06 20:16 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-06 20:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-06 20:16 -------
*** Bug 21426 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amu at alum dot mit dot edu


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


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

end of thread, other threads:[~2005-05-06 20:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-12 18:46 [Bug c++/19404] New: error: 'QSizePolicy::<anonymous enum>' uses anonymous type Woebbeking at web dot de
2005-01-12 18:53 ` [Bug c++/19404] [4.0 Regression] " pinskia at gcc dot gnu dot org
2005-01-12 20:35 ` [Bug c++/19404] [4.0 Regression] anonymous types and templates and rejecting valid code pinskia at gcc dot gnu dot org
2005-01-31  6:22 ` mmitchel at gcc dot gnu dot org
2005-04-08 14:36 ` lars at trolltech dot com
2005-04-08 15:34 ` mark at codesourcery dot com
2005-04-08 16:35 ` lars at trolltech dot com
2005-04-27  9:15 ` pcarlini at suse dot de
2005-05-06 20:16 ` pinskia at gcc dot gnu dot 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).