Bug 29596 - overloaded function not found
Summary: overloaded function not found
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-25 21:43 UTC by Christian Schlotter
Modified: 2006-10-30 17:26 UTC (History)
1 user (show)

See Also:
Host: i686-pc-gnu-linux
Target: i686-pc-gnu-linux
Build: i686-pc-gnu-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments
test.cpp (sample program that does not compile) (275 bytes, text/plain)
2006-10-25 21:45 UTC, Christian Schlotter
Details
output of g++ test.cpp -o test (529 bytes, text/plain)
2006-10-25 21:50 UTC, Christian Schlotter
Details
output of Visual C++ .NET 2003 plus output of compiled program (261 bytes, text/plain)
2006-10-25 21:51 UTC, Christian Schlotter
Details
test2.cpp (sample program that does not compile) (203 bytes, text/plain)
2006-10-27 09:04 UTC, Christian Schlotter
Details
output of 'g++ test2.cpp -o test2' (282 bytes, text/plain)
2006-10-27 09:05 UTC, Christian Schlotter
Details
output of compiler shipped with MS Visual C++ 2005 Express Edition and program output (194 bytes, text/plain)
2006-10-27 09:06 UTC, Christian Schlotter
Details
unincluded testcase (24.63 KB, application/octet-stream)
2006-10-27 11:05 UTC, Richard Biener
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Schlotter 2006-10-25 21:43:55 UTC
Please find attached a sample program, which does not compile.

Unfortunately this program depends on boost.  I use the current boost version 1.33.1.  The include files "algorithm" and "iostream" are the ones belonging to gcc-4.1.1.
Comment 1 Christian Schlotter 2006-10-25 21:45:01 UTC
Created attachment 12493 [details]
test.cpp (sample program that does not compile)

This program does not compile (commandline g++ test.cpp -o test)
Comment 2 Andrew Pinski 2006-10-25 21:48:00 UTC
Can you provide the preprocessed source which you can get via -save-temps and it will be called something .ii.
Also you can provide the error message you get?
Comment 3 Christian Schlotter 2006-10-25 21:50:14 UTC
Created attachment 12494 [details]
output of g++ test.cpp -o test
Comment 4 Christian Schlotter 2006-10-25 21:51:41 UTC
Created attachment 12495 [details]
output of Visual C++ .NET 2003 plus output of compiled program
Comment 5 Christian Schlotter 2006-10-25 21:53:14 UTC
test.ii produced by `g++ -v -save-temps test.cpp -o test' is to bug for bugzilla -- you can find it here:
http://schlotter.org/pub/test.ii (1.2MB)
Comment 6 Christian Schlotter 2006-10-25 21:57:36 UTC
Remark to test.cpp:23:
        std::cout << boost::lambda::_1 << '\n'

This should find the overloaded operator<< defined in boost/tuple_io.hpp.
Comment 7 Christian Schlotter 2006-10-27 09:04:46 UTC
Created attachment 12500 [details]
test2.cpp (sample program that does not compile)

I managed to simplify the program.
Comment 8 Christian Schlotter 2006-10-27 09:05:19 UTC
Created attachment 12501 [details]
output of 'g++ test2.cpp -o test2'
Comment 9 Christian Schlotter 2006-10-27 09:06:14 UTC
Created attachment 12502 [details]
output of compiler shipped with MS Visual C++ 2005 Express Edition and program output
Comment 10 Christian Schlotter 2006-10-27 09:06:53 UTC
test2.ii produced by `g++ -v -save-temps test2.cpp -o test2' is to big for
bugzilla -- you can find it here:
http://schlotter.org/pub/test2.ii (1.1MB)
Comment 11 Richard Biener 2006-10-27 11:04:43 UTC
I believe the testcase is invalid.  EDG says:

test.cpp(5824): error: no instance of overloaded function "boost::lambda::lambda_functor<T>::operator() [with T=boost::lambda::placeholder<1>]" matches the argument list
            argument types are: (std::pair<int, int>)
            object type is: boost::lambda::placeholder1_type
      std::cout << (boost::lambda::_1)(std::make_pair(a, b)) << std::endl;
                   ^

compilation aborted for test.cpp (code 2)
Comment 12 Richard Biener 2006-10-27 11:05:23 UTC
Created attachment 12503 [details]
unincluded testcase
Comment 13 Christian Schlotter 2006-10-30 17:12:27 UTC
(In reply to comment #11)
> I believe the testcase is invalid.

You're right, therefore I'm closing this bug.  The author of the Boost.Lambda library, Jaakko Järvi, kindly pointed my to a section of the library documentation, where it is written that arguments to lambda functions can't be non-const rvalues[1].

The following patch corrects the test case:
--- test2.cpp.~1~       2006-10-27 11:02:14.000000000 +0200
+++ test2.cpp   2006-10-30 18:05:06.000000000 +0100
@@ -11,6 +11,8 @@
 int main()
 {
     int a = 1, b = 2;
-    std::cout << (boost::lambda::_1)(std::make_pair(a, b)) << std::endl;
+    std::cout
+        << (boost::lambda::_1)(boost::lambda::make_const(std::make_pair(a, b)))
+        << std::endl;
     return 0;
 }

I don't know why it compiles cleanly on VC++, though.

Best regards
Christian

[1] http://www.boost.org/doc/html/lambda/using_library.html#lambda.actual_arguments_to_lambda_functors
Comment 14 Christian Schlotter 2006-10-30 17:26:54 UTC
However, my initial testcase (attachment #12493 [details]) does still not compile, so it seems I have simplified it wrongly.  I will check this back and reopen the bug accordingly.