public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51829] New: decltype() deduces non-const but only in a template
@ 2012-01-11 21:30 bugs at sehe dot nl
  2012-01-11 21:32 ` [Bug c++/51829] " bugs at sehe dot nl
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: bugs at sehe dot nl @ 2012-01-11 21:30 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51829
           Summary: decltype() deduces non-const but only in a template
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: bugs@sehe.nl


The problem rejects a valid `auto expr = ...;` initialization. I have reduced
things to the following (full preprocessed version attached)

The template arguments aren't relevant (unused).

    #include <boost/spirit/include/qi_eps.hpp>

    template <typename> // without template, works!
    void bug()
    {
        const auto& e1 = boost::spirit::qi::eps(false);
        const auto& e2 = e1 | '1';

        decltype(boost::spirit::qi::eps(false) | '1') *notok;

        notok = &e2; // FAILS if in template function
    }

    int main() { bug<void>(); }

By using a pointer declaration for `notok` I was able to use demangling to
print the difference between the deduced types:

    boost::proto::exprns_::expr<boost::proto::tagns_::tag::bitwise_or,
boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::spirit::terminal_ex<boost::spirit::tag::eps,
boost::fusion::vector1<bool> > >, 0l> const&,
boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<char const&>, 0l> >, 2l>
    boost::proto::exprns_::expr<boost::proto::tagns_::tag::bitwise_or,
   
boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,
   
boost::proto::argsns_::term<boost::spirit::terminal_ex<boost::spirit::tag::eps,
    boost::fusion::vector1<bool> > >, 0l> CONST&,
    boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,
    boost::proto::argsns_::term<char const&>, 0l> >, 2l> const*

The 'CONST' I capitalized in the middle, is missing when the decltype() is in a
function template, which prevents the assignment.

I don't know how to further reduce the testcase at this point in time. MSVC
2010 compiles the code without problem.


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

* [Bug c++/51829] decltype() deduces non-const but only in a template
  2012-01-11 21:30 [Bug c++/51829] New: decltype() deduces non-const but only in a template bugs at sehe dot nl
@ 2012-01-11 21:32 ` bugs at sehe dot nl
  2012-01-12  0:30 ` bugs at sehe dot nl
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bugs at sehe dot nl @ 2012-01-11 21:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Seth Heeren <bugs at sehe dot nl> 2012-01-11 21:32:11 UTC ---
Created attachment 26302
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26302
(gz) preprocessed source for the minimal testcase


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

* [Bug c++/51829] decltype() deduces non-const but only in a template
  2012-01-11 21:30 [Bug c++/51829] New: decltype() deduces non-const but only in a template bugs at sehe dot nl
  2012-01-11 21:32 ` [Bug c++/51829] " bugs at sehe dot nl
@ 2012-01-12  0:30 ` bugs at sehe dot nl
  2012-01-13 12:05 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bugs at sehe dot nl @ 2012-01-12  0:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Seth Heeren <bugs at sehe dot nl> 2012-01-12 00:30:36 UTC ---
To clarify, the valid code that was rejected looks like:

     auto expr = boost::spirit::qi::eps(false) | '1';

this might explain the 'strange' breaking up into e1 and e2 for the minimal
testcase. 

HTH


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

* [Bug c++/51829] decltype() deduces non-const but only in a template
  2012-01-11 21:30 [Bug c++/51829] New: decltype() deduces non-const but only in a template bugs at sehe dot nl
  2012-01-11 21:32 ` [Bug c++/51829] " bugs at sehe dot nl
  2012-01-12  0:30 ` bugs at sehe dot nl
@ 2012-01-13 12:05 ` paolo.carlini at oracle dot com
  2012-05-12 23:04 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-01-13 12:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-01-13 12:04:02 UTC ---
Please do your best to distill a testcase of manageable size, a few KBs at
most: http://gcc.gnu.org/wiki/A_guide_to_testcase_reduction


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

* [Bug c++/51829] decltype() deduces non-const but only in a template
  2012-01-11 21:30 [Bug c++/51829] New: decltype() deduces non-const but only in a template bugs at sehe dot nl
                   ` (2 preceding siblings ...)
  2012-01-13 12:05 ` paolo.carlini at oracle dot com
@ 2012-05-12 23:04 ` paolo.carlini at oracle dot com
  2012-05-13  3:38 ` bugs at sehe dot nl
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-12 23:04 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2012-05-12
                 CC|bugs at sehe dot nl         |
     Ever Confirmed|0                           |1

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-12 22:46:31 UTC ---
Still waiting.


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

* [Bug c++/51829] decltype() deduces non-const but only in a template
  2012-01-11 21:30 [Bug c++/51829] New: decltype() deduces non-const but only in a template bugs at sehe dot nl
                   ` (3 preceding siblings ...)
  2012-05-12 23:04 ` paolo.carlini at oracle dot com
@ 2012-05-13  3:38 ` bugs at sehe dot nl
  2012-05-13  9:37 ` glisse at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bugs at sehe dot nl @ 2012-05-13  3:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Seth Heeren <bugs at sehe dot nl> 2012-05-13 00:05:00 UTC ---
On 13-05-12 00:46, paolo.carlini at oracle dot com wrote:
> Still waiting.
Really. Well, to be honest, I can't afford to spend even more time 
minimizing that any further. I have to pick priorities.

For quick win, of course, you could check whether the problem still 
exists with GCC 4.7 or dev versions. It might have been fixed in the 
process of other development/fixes.

God knows I had spent over 6 hours trying to minimize that by manually 
decimating the preprocessed sources even before initially posting the 
report. And it wasn't even my own bug; it was a support call on the 
[spirit-general] list.

I don't think it is worth my time to **learn** how to further reduce the 
testcase further, since that  seems to be a highly specialized craft 
and, tools could do a good job.
I'd be rather surprised if the GCC team didn't have just such tools, as 
well as people skilled and experienced in using them.

All of the above would require a lot of time on my side, and sadly I 
don't have it.

Regards
Seth


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

* [Bug c++/51829] decltype() deduces non-const but only in a template
  2012-01-11 21:30 [Bug c++/51829] New: decltype() deduces non-const but only in a template bugs at sehe dot nl
                   ` (4 preceding siblings ...)
  2012-05-13  3:38 ` bugs at sehe dot nl
@ 2012-05-13  9:37 ` glisse at gcc dot gnu.org
  2012-10-14 15:49 ` paolo.carlini at oracle dot com
  2012-10-15 21:14 ` bugs at sehe dot nl
  7 siblings, 0 replies; 9+ messages in thread
From: glisse at gcc dot gnu.org @ 2012-05-13  9:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Marc Glisse <glisse at gcc dot gnu.org> 2012-05-13 09:06:42 UTC ---
With boost 1.49, g++-4.7 compiles the code just fine, while g++-4.6 gives:

u.cc: In function ‘void bug() [with <template-parameter-1-1> = void]’:
u.cc:14:24:   instantiated from here
u.cc:11:3: error: cannot convert ‘const type {aka const
boost::proto::exprns_::expr<boost::proto::tagns_::tag::address_of,
boost::proto::argsns_::list1<const
boost::proto::exprns_::expr<boost::proto::tagns_::tag::bitwise_or,
boost::proto::argsns_::list2<const
boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::spirit::terminal_ex<boost::spirit::tag::eps,
boost::fusion::vector1<bool> > >, 0l>&,
boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<const char&>, 0l> >, 2l>&>, 1l>}’ to ‘const type*
{aka const boost::proto::exprns_::expr<boost::proto::tagns_::tag::bitwise_or,
boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::spirit::terminal_ex<boost::spirit::tag::eps,
boost::fusion::vector1<bool> > >, 0l>&,
boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<const char&>, 0l> >, 2l>*}’ in assignment


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

* [Bug c++/51829] decltype() deduces non-const but only in a template
  2012-01-11 21:30 [Bug c++/51829] New: decltype() deduces non-const but only in a template bugs at sehe dot nl
                   ` (5 preceding siblings ...)
  2012-05-13  9:37 ` glisse at gcc dot gnu.org
@ 2012-10-14 15:49 ` paolo.carlini at oracle dot com
  2012-10-15 21:14 ` bugs at sehe dot nl
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-14 15:49 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
      Known to work|                            |4.7.0, 4.8.0
         Resolution|                            |FIXED

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-14 15:49:08 UTC ---
Closing as fixed.


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

* [Bug c++/51829] decltype() deduces non-const but only in a template
  2012-01-11 21:30 [Bug c++/51829] New: decltype() deduces non-const but only in a template bugs at sehe dot nl
                   ` (6 preceding siblings ...)
  2012-10-14 15:49 ` paolo.carlini at oracle dot com
@ 2012-10-15 21:14 ` bugs at sehe dot nl
  7 siblings, 0 replies; 9+ messages in thread
From: bugs at sehe dot nl @ 2012-10-15 21:14 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #8 from Seth Heeren <bugs at sehe dot nl> 2012-10-15 21:14:45 UTC ---
That is great. I confirmed this with gcc version 4.7.0 20111010 (experimental)
[trunk revision 179769]

The problem has been solved.

Thanks everyone,
Seth


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

end of thread, other threads:[~2012-10-15 21:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-11 21:30 [Bug c++/51829] New: decltype() deduces non-const but only in a template bugs at sehe dot nl
2012-01-11 21:32 ` [Bug c++/51829] " bugs at sehe dot nl
2012-01-12  0:30 ` bugs at sehe dot nl
2012-01-13 12:05 ` paolo.carlini at oracle dot com
2012-05-12 23:04 ` paolo.carlini at oracle dot com
2012-05-13  3:38 ` bugs at sehe dot nl
2012-05-13  9:37 ` glisse at gcc dot gnu.org
2012-10-14 15:49 ` paolo.carlini at oracle dot com
2012-10-15 21:14 ` bugs at sehe dot nl

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