|
Boost : |
From: David Brownstein (David_at_[hidden])
Date: 2002-08-02 15:30:49
With MSVC6, it looks like the compiler is generating the same mangled name
for each instantiation of call_it(), as the linker complains:
fatal error LNK1179: invalid or corrupt file: duplicate comdat
"?call_it@@YAXP6AXH_at_Z@Z"
changing the return value of f2() fixes this problem... ;-) (but not
generally, I have no idea?)
David
----- Original Message -----
From: "Gennaro Prota" <gennaro_prota_at_[hidden]>
Newsgroups: gmane.comp.lib.boost.devel
To: <boost_at_[hidden]>
Sent: Friday, August 02, 2002 11:59 AM
Subject: [boost] Re: Why does this work?
> On Fri, 2 Aug 2002 21:28:05 +0300, "Peter Dimov" <pdimov_at_[hidden]>
> wrote:
>
> [...]
> >
> >Compiler bug/extension; there are compilers that diagnose it. To see that
> >it's a bug, add this:
> >
> >> int
> >> foo(int a = 1, int b = 2)
> >> { return a + b; }
> >
> >int foo2(int a = -1, int b = -2) { return a + b; }
> >
> >> ///////////////////////////////////////
> >> int
> >> main()
> >> {
> >> typedef f_stubs<int(int a, int b)> f_stubs;
> >>
> >> cout << f_stubs::f0(foo) () << endl;
> > cout << f_stubs::f0(foo2) () << endl;
> >> }
>
>
> AFAIK this is one of the more widespread bug in C++ implementations.
> When you give two functions of the same type, like in Peter's example,
> there are compilers which fail to link and others that link but use
> the same default arguments used for the first call (in the example, 1
> and 2). Here's a simpler example:
>
> template <typename pointerT>
> inline void call_it(pointerT p)
> {
> (*p)();
> }
>
> void f(int i = 0) { cout << i << '\n'; }
> void f2 (int i = 5) { cout << i << '\n'; }
>
>
> int main ()
> {
> call_it(&f);
> call_it(&f2);
> }
>
>
>
> I wonder if there's any easy workaround.
>
>
> Genny.
>
>
>
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk