public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/24215]  New: pragma interface in included file with same name
@ 2005-10-05 15:05 vbato dot bugs at gmail dot com
  2005-10-05 16:27 ` [Bug c++/24215] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vbato dot bugs at gmail dot com @ 2005-10-05 15:05 UTC (permalink / raw)
  To: gcc-bugs

If in a .h file you include another file with the same name, but in a different
directory, that contains a #pragma interface, it seems that the #pragma
interface gets extended to the current file, past the end of the included file.

In the following example there are three files:
a.h   : contains the declaration of a class
a.cpp : includes a.h and contains the implementation of the class.
b/a.h : this is included in a.h. It has the same name as a.h, but is in a
different directory. It contains a #pragma interface

When you compile a.cpp, it doesn't create the virtual table for the Test class.
It looks like the '#pragma interface' is extended to a.h, and since it doesn't
find the corresponding '#pragma implementation' it doesn't include the virtual
table for the class in the object file.

Here's the example:

=====
$ cat a.cpp
#include "a.h"

Test::Test(){}

void Test::f(){}

$ cat a.h
#include "b/a.h"

class Test
{
    public:
        Test();
        virtual void f();
};

$ cat b/a.h

#pragma interface "a.h"
===

If you compile a.cpp, the virtual table for class Test is not created in the
object file:

$ g++ a.cpp
$ nm -C a.o
00000020 T Test::f()
00000010 T Test::Test()
00000000 T Test::Test()
         U vtable for Test

If you rename the file a.h to a2.h and change a.cpp accordingly, you get:
$ nm -C a.o
00000020 T Test::f()
00000010 T Test::Test()
00000000 T Test::Test()
00000000 V typeinfo for Test
00000000 V typeinfo name for Test
00000000 V vtable for Test
         U vtable for __cxxabiv1::__class_type_info

Which should be the correct behaviour.


I've seen this since 4.0. It wasn't present in 3.3.
I've tested it both with gcc 4.0.1 and with the latest 4.1 cvs snapshot:

$ g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.1-20051001/configure --prefix=/home/vbato/gcc41
Thread model: posix
gcc version 4.1.0 20051001 (experimental)


-- 
           Summary: pragma interface in included file with same name
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vbato dot bugs at gmail dot com


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


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

* [Bug c++/24215] [4.0/4.1 Regression] pragma interface in included file with same name
  2005-10-05 15:05 [Bug c++/24215] New: pragma interface in included file with same name vbato dot bugs at gmail dot com
@ 2005-10-05 16:27 ` pinskia at gcc dot gnu dot org
  2005-10-07 17:26 ` janis187 at us dot ibm dot com
  2005-10-11  6:49 ` mmitchel at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-05 16:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2005-10-05 16:27 -------
Confirmed, a regression from 3.4.0.
Was introduced between "3.5.0 20040909" and "4.0.0 20041124".


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mmitchel at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
      Known to fail|                            |4.0.0 4.1.0
      Known to work|                            |3.4.0
   Last reconfirmed|0000-00-00 00:00:00         |2005-10-05 16:27:49
               date|                            |
            Summary|pragma interface in included|[4.0/4.1 Regression] pragma
                   |file with same name         |interface in included file
                   |                            |with same name
   Target Milestone|---                         |4.0.3


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


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

* [Bug c++/24215] [4.0/4.1 Regression] pragma interface in included file with same name
  2005-10-05 15:05 [Bug c++/24215] New: pragma interface in included file with same name vbato dot bugs at gmail dot com
  2005-10-05 16:27 ` [Bug c++/24215] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
@ 2005-10-07 17:26 ` janis187 at us dot ibm dot com
  2005-10-11  6:49 ` mmitchel at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: janis187 at us dot ibm dot com @ 2005-10-07 17:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from janis187 at us dot ibm dot com  2005-10-07 17:26 -------
A regression hunt identified this large patch from Zack Weinberg and
Matt Austern:

  http://gcc.gnu.org/ml/gcc-cvs/2004-09/msg00920.html


-- 


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


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

* [Bug c++/24215] [4.0/4.1 Regression] pragma interface in included file with same name
  2005-10-05 15:05 [Bug c++/24215] New: pragma interface in included file with same name vbato dot bugs at gmail dot com
  2005-10-05 16:27 ` [Bug c++/24215] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
  2005-10-07 17:26 ` janis187 at us dot ibm dot com
@ 2005-10-11  6:49 ` mmitchel at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-10-11  6:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from mmitchel at gcc dot gnu dot org  2005-10-11 06:49 -------
The semantics of #pragma interface are not entirely well-specified in this
case.  However, the documentation does suggest that you use an explicit
subdirectory when you have multiple headers with the same name in different
directories.  Indeed, using:

#pragma interface "b/a.h"

fixes the problem.

Therefore, I'm going to close this as INVALID.


-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2005-10-11  6:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-05 15:05 [Bug c++/24215] New: pragma interface in included file with same name vbato dot bugs at gmail dot com
2005-10-05 16:27 ` [Bug c++/24215] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
2005-10-07 17:26 ` janis187 at us dot ibm dot com
2005-10-11  6:49 ` mmitchel at gcc dot gnu dot org

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