public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12216] New: Bad "implicit typename" warning
@ 2003-09-08 21:01 igodard at pacbell dot net
  2003-09-08 21:02 ` [Bug c++/12216] " igodard at pacbell dot net
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: igodard at pacbell dot net @ 2003-09-08 21:01 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Bad "implicit typename" warning
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net
                CC: gcc-bugs at gcc dot gnu dot org

3.3.1 warns about implicit typename on identifier declared in an (inherited) typedef. A typedef can't be anything but a type, so the warning is incorrect. If you attempt to remove the warning by uncommenting the "/* typename */" then you get a compile error.

Ivan


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

* [Bug c++/12216] Bad "implicit typename" warning
  2003-09-08 21:01 [Bug c++/12216] New: Bad "implicit typename" warning igodard at pacbell dot net
@ 2003-09-08 21:02 ` igodard at pacbell dot net
  2003-09-08 21:03 ` igodard at pacbell dot net
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: igodard at pacbell dot net @ 2003-09-08 21:02 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From igodard at pacbell dot net  2003-09-08 21:02 -------
Created an attachment (id=4720)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=4720&action=view)
Compiler output (-v -save-temps)


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

* [Bug c++/12216] Bad "implicit typename" warning
  2003-09-08 21:01 [Bug c++/12216] New: Bad "implicit typename" warning igodard at pacbell dot net
  2003-09-08 21:02 ` [Bug c++/12216] " igodard at pacbell dot net
@ 2003-09-08 21:03 ` igodard at pacbell dot net
  2003-09-08 21:41 ` bangerth at dealii dot org
  2003-09-09  7:02 ` igodard at pacbell dot net
  3 siblings, 0 replies; 5+ messages in thread
From: igodard at pacbell dot net @ 2003-09-08 21:03 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From igodard at pacbell dot net  2003-09-08 21:03 -------
Created an attachment (id=4721)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=4721&action=view)
Source code (-save-temps)


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

* [Bug c++/12216] Bad "implicit typename" warning
  2003-09-08 21:01 [Bug c++/12216] New: Bad "implicit typename" warning igodard at pacbell dot net
  2003-09-08 21:02 ` [Bug c++/12216] " igodard at pacbell dot net
  2003-09-08 21:03 ` igodard at pacbell dot net
@ 2003-09-08 21:41 ` bangerth at dealii dot org
  2003-09-09  7:02 ` igodard at pacbell dot net
  3 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2003-09-08 21:41 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


bangerth at dealii dot org changed:

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


------- Additional Comments From bangerth at dealii dot org  2003-09-08 21:41 -------
No. Given your code
-------------------------
template<typename I>
class C : public std::iterator<
              typename std::iterator_traits<I>::Category,
              typename std::iterator_traits<I>::value_type,
              typename std::iterator_traits<I>::difference_type,
              typename std::iterator_traits<I>::pointer,
              typename std::iterator_traits<I>::reference
                                                        > {
public:
                                C(I i) : iter(i) {}

        value_type operator*() const { return *iter; }
private:
        I iter;
        };

int main() {
        }

---------------------------------
the typedef value_type is not visible with two-stage lookup. Your code
is thus invalid, but gcc up to and including 3.3.x accepts it. You
really need to write the thing with the typename, but including the
classname, i.e.
  typename C<I>::value_type
or
  typename std::iterator<...>::value_type

The point is that you need to make the name of the type dependent, so
that it is looked up on instantiation, rather than declaration time. So
the thing before :: must be template dependent, but then you also need
the typename.

W.


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

* [Bug c++/12216] Bad "implicit typename" warning
  2003-09-08 21:01 [Bug c++/12216] New: Bad "implicit typename" warning igodard at pacbell dot net
                   ` (2 preceding siblings ...)
  2003-09-08 21:41 ` bangerth at dealii dot org
@ 2003-09-09  7:02 ` igodard at pacbell dot net
  3 siblings, 0 replies; 5+ messages in thread
From: igodard at pacbell dot net @ 2003-09-09  7:02 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From igodard at pacbell dot net  2003-09-09 07:02 -------
Subject: Re:  Bad "implicit typename" warning

Understood. Thanks.

Ivan

----- Original Message ----- 
From: "bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org>
To: <igodard@pacbell.net>
Sent: Monday, September 08, 2003 2:41 PM
Subject: [Bug c++/12216] Bad "implicit typename" warning


> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12216
>
>
> bangerth at dealii dot org changed:
>
>            What    |Removed                     |Added
> --------------------------------------------------------------------------
--
>              Status|UNCONFIRMED                 |RESOLVED
>          Resolution|                            |INVALID
>
>
> ------- Additional Comments From bangerth at dealii dot org  2003-09-08
21:41 -------
> No. Given your code
> -------------------------
> template<typename I>
> class C : public std::iterator<
>               typename std::iterator_traits<I>::Category,
>               typename std::iterator_traits<I>::value_type,
>               typename std::iterator_traits<I>::difference_type,
>               typename std::iterator_traits<I>::pointer,
>               typename std::iterator_traits<I>::reference
>                                                         > {
> public:
>                                 C(I i) : iter(i) {}
>
>         value_type operator*() const { return *iter; }
> private:
>         I iter;
>         };
>
> int main() {
>         }
>
> ---------------------------------
> the typedef value_type is not visible with two-stage lookup. Your code
> is thus invalid, but gcc up to and including 3.3.x accepts it. You
> really need to write the thing with the typename, but including the
> classname, i.e.
>   typename C<I>::value_type
> or
>   typename std::iterator<...>::value_type
>
> The point is that you need to make the name of the type dependent, so
> that it is looked up on instantiation, rather than declaration time. So
> the thing before :: must be template dependent, but then you also need
> the typename.
>
> W.
>
>
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.


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

end of thread, other threads:[~2003-09-09  7:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-08 21:01 [Bug c++/12216] New: Bad "implicit typename" warning igodard at pacbell dot net
2003-09-08 21:02 ` [Bug c++/12216] " igodard at pacbell dot net
2003-09-08 21:03 ` igodard at pacbell dot net
2003-09-08 21:41 ` bangerth at dealii dot org
2003-09-09  7:02 ` igodard at pacbell dot net

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