This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug c++/14962] [3.3/3.4/3.5 regression] g++ ignores #pragma redefine_extname


------- Additional Comments From ebotcazou at gcc dot gnu dot org  2004-05-04 08:06 -------
I think you slightly misunderstood the semantics of #pragma redefine_extname
when you said: "I've then edited both files to comment out the definitions of
statvfs and fstatvfs. This should make no difference to the compilation, since
these names have been redifined by the pragma immediately preceeding them to
statvfs64 and fstatvfs64 (due to the -D options I added to the compiler flags)".

This does make a difference: the pragma redefines the *external* name only, not
the internal name used within the compilation unit.  You didn't see the problem
with the C compiler but passing -Wall would have given:

statfs_test.c:10: warning: implicit declaration of function `statvfs'

Of course this is a hard error with the C++ compiler.  So you can't comment out
the declaration of the functions, even if they have been "pragma-ized".


A good news is that the mechanism is not that broken in the C++ compiler.  For
example, it works for the following code:

#pragma redefine_extname old_name1 new_name1

extern "C" int old_name1(void);

extern "C" int old_name2(void) asm("new_name2");


int foo1(void)
{
  return old_name1();
}

int foo2(void)
{
  return old_name2();
}

The assembly contains new_name1 and new_name2 only.


The mechanism doesn't work with your testcase because of an identifier
overloading problem.  We have:

typedef struct statvfs {
        unsigned long f_bsize;
        unsigned long f_frsize;
        fsblkcnt_t f_blocks;
        fsblkcnt_t f_bfree;
        fsblkcnt_t f_bavail;
        fsfilcnt_t f_files;
        fsfilcnt_t f_ffree;
        fsfilcnt_t f_favail;
        unsigned long f_fsid;
        char f_basetype[16];

        unsigned long f_flag;
        unsigned long f_namemax;
        char f_fstr[32];

        unsigned long f_filler[16];

} statvfs_t;

pragma redefine_extname statvfs statvfs64

int statvfs(const char *, statvfs_t *);


If you change "statvfs" to anything else in "struct statvfs", "statvfs64" will
be emitted in the assembly output instead of "statvfs" for the function call.

Now we have to devise a fix...

-- 


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


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