This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: objdump : inaccurate demangling for foo(char* const)


YES, there ARE a noticeable difference between GCC 3.2  and MS VisualC 7.1

struct A {
    virtual void foo(char* a) { std::cout << "A"; }
};

struct B: public A {
    virtual void foo(char* const a) { std::cout << "B"; }
};

int main() {
    B b;
    A* a = &b;
    a->foo("");
}

This example prints "A" in MSVC, and "B" in GCC.

In the plain case, the behavior is identical:

void foo1(char* a) {}
void foo2(char* const a) {}

>From the caller function point of view, signatures of this functions (except name,
apparently)
should be identical - no matter, that parameter can't be changed _inside_ the function.
If you can pass a pointer to foo1() , so you can pass it to foo2() and vice versa.

If you declare pointers
  typedef void (*PF1)(char*);
  typedef void (*PF2)(char*const);
you can assign any foo to each PF.

IMHO, GCC seems  more consistent.

Of course, this is not the issue of cygwin port of GCC, you should ask GCC mailing list.
Let me know, if you'll find the correct answer.

=======
Alex.



"Alex Vinokur" <alexvn@connect.to> wrote in message bke0qt$8l6$1@sea.gmane.org">news:bke0qt$8l6$1@sea.gmane.org...
>
> "Alex Vinokur" <alexvn@connect.to> wrote in message bkdtn1$597$2@sea.gmane.org">news:bkdtn1$597$2@sea.gmane.org...
> > ==========================================
> > Windows 2000 Professional
> > CYGWIN_NT-5.0 1.5.4(0.94/3/2)
> > GNU gcc version 3.2 20020927 (prerelease)
> > GNU objdump 2.14.90 20030901
> > ==========================================
> >
>
> Updated question about objdump.
>
> Low-level and user-level symbol names of foo2(char* const) are foo2(char*)
>
> --------- C++ code ---------
> void foo1 (char*) {}
> void foo2 (char* const) {}
> ----------------------------
>
>
> --------- objdump : Fragments ---------
> $ objdump -Cd t.o
>
> t.o:     file format pe-i386
>
> Disassembly of section .text:
>
> 00000000 <__Z4foo1Pc>:    // OK
>
> 00000006 <__Z4foo2Pc>:    // char*, not char* const
>
>
> $ objdump -d t.o
>
> t.o:     file format pe-i386
>
> Disassembly of section .text:
>
> 00000000 <foo1(char*)>:    // OK
>
>
> 00000006 <foo2(char*)>:    // Not char* const
>
> --------------------------------------
>
> So, is it inaccuracy or convention?
>
>
>    =====================================
>    Alex Vinokur
>      mailto:alexvn@connect.to
>      http://mathforum.org/library/view/10978.html
>    =====================================
>
>
>
>




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]