public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58047] New: parse error with typedef introduced from base class
@ 2013-08-01 16:17 roshan.shariff at gmail dot com
  2013-08-01 22:23 ` [Bug c++/58047] " paolo.carlini at oracle dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: roshan.shariff at gmail dot com @ 2013-08-01 16:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58047
           Summary: parse error with typedef introduced from base class
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roshan.shariff at gmail dot com

Created attachment 30585
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30585&action=edit
Test case exhibiting parse error

Trying to compile the attached code with g++ 4.8.1 gives an error. The code
compiles and works fine with clang.

template <int N>
struct print_arg {
  void print () { std::cout << N << '\n'; }
};

struct const_holder {
  static constexpr int CONSTANT = 42;
};

template <typename T>
struct identity {
  using type = T;
};

template <class T>
struct test_case : public identity<T> {
  using typename identity<T>::type;
  print_arg<type::CONSTANT> printer; // <- parse error
};

int main () {
  // Should print 42
  test_case<const_holder>().printer.print();
}

The attached file contains two variants of the above code that do work fine.
Trying to compile it produces the following error message:

$ g++ -std=c++11 gccbug.cpp -o gccbug
gccbug.cpp:31:3: error: parse error in template argument list
   print_arg<type::CONSTANT> printer;
   ^
gccbug.cpp: In instantiation of 'struct test_case<const_holder>':
gccbug.cpp:46:27:   required from here
gccbug.cpp:31:29: error: expected primary-expression
   print_arg<type::CONSTANT> printer;
                             ^
gccbug.cpp: In function 'int main()':
gccbug.cpp:46:29: error: 'struct test_case<const_holder>' has no member named
'printer'
   test_case<const_holder>().printer.print();


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

* [Bug c++/58047] parse error with typedef introduced from base class
  2013-08-01 16:17 [Bug c++/58047] New: parse error with typedef introduced from base class roshan.shariff at gmail dot com
@ 2013-08-01 22:23 ` paolo.carlini at oracle dot com
  2013-08-02  9:53 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-01 22:23 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-08-01
                 CC|roshan.shariff at gmail dot com    |
     Ever confirmed|0                           |1


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

* [Bug c++/58047] parse error with typedef introduced from base class
  2013-08-01 16:17 [Bug c++/58047] New: parse error with typedef introduced from base class roshan.shariff at gmail dot com
  2013-08-01 22:23 ` [Bug c++/58047] " paolo.carlini at oracle dot com
@ 2013-08-02  9:53 ` paolo.carlini at oracle dot com
  2013-08-02  9:54 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-02  9:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Let's have this at hand, just c++98:

template <int N>
struct print_arg { };

struct const_holder {
  static const int CONSTANT = 42;
};

template <typename T>
struct identity {
  typedef T type;
};

template <class T>
struct test_case : public identity<T> {
  using typename identity<T>::type;
  print_arg<type::CONSTANT> printer;
};

template struct test_case<const_holder>;


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

* [Bug c++/58047] parse error with typedef introduced from base class
  2013-08-01 16:17 [Bug c++/58047] New: parse error with typedef introduced from base class roshan.shariff at gmail dot com
  2013-08-01 22:23 ` [Bug c++/58047] " paolo.carlini at oracle dot com
  2013-08-02  9:53 ` paolo.carlini at oracle dot com
@ 2013-08-02  9:54 ` paolo.carlini at oracle dot com
  2013-08-02 10:00 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-02  9:54 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fabien at gcc dot gnu.org

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
... hard to believe we don't have a Dup.


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

* [Bug c++/58047] parse error with typedef introduced from base class
  2013-08-01 16:17 [Bug c++/58047] New: parse error with typedef introduced from base class roshan.shariff at gmail dot com
                   ` (2 preceding siblings ...)
  2013-08-02  9:54 ` paolo.carlini at oracle dot com
@ 2013-08-02 10:00 ` paolo.carlini at oracle dot com
  2013-08-03 10:54 ` paolo.carlini at oracle dot com
  2014-02-02 20:08 ` fabien at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-02 10:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Seems closely related to PR37140.


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

* [Bug c++/58047] parse error with typedef introduced from base class
  2013-08-01 16:17 [Bug c++/58047] New: parse error with typedef introduced from base class roshan.shariff at gmail dot com
                   ` (3 preceding siblings ...)
  2013-08-02 10:00 ` paolo.carlini at oracle dot com
@ 2013-08-03 10:54 ` paolo.carlini at oracle dot com
  2014-02-02 20:08 ` fabien at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-03 10:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
You should ;) Seriously, when committing a patch I think that it's a good
practice to double check it on the duplicates, even if everything goes well
consider adding sufficiently different testcases coming from the dups. The
division of labor between triaging and fixing will never be perfect!

Thanks for working on this!


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

* [Bug c++/58047] parse error with typedef introduced from base class
  2013-08-01 16:17 [Bug c++/58047] New: parse error with typedef introduced from base class roshan.shariff at gmail dot com
                   ` (4 preceding siblings ...)
  2013-08-03 10:54 ` paolo.carlini at oracle dot com
@ 2014-02-02 20:08 ` fabien at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: fabien at gcc dot gnu.org @ 2014-02-02 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

fabien at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #6 from fabien at gcc dot gnu.org ---
marked as duplicate

*** This bug has been marked as a duplicate of bug 37140 ***


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

end of thread, other threads:[~2014-02-02 20:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-01 16:17 [Bug c++/58047] New: parse error with typedef introduced from base class roshan.shariff at gmail dot com
2013-08-01 22:23 ` [Bug c++/58047] " paolo.carlini at oracle dot com
2013-08-02  9:53 ` paolo.carlini at oracle dot com
2013-08-02  9:54 ` paolo.carlini at oracle dot com
2013-08-02 10:00 ` paolo.carlini at oracle dot com
2013-08-03 10:54 ` paolo.carlini at oracle dot com
2014-02-02 20:08 ` fabien 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).