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++/13086] New: warning: `e' has incomplete type without location


The following piece of code:

/tmp % cat -n foo.cc                                             nostromo Err 1
     1  class Exp;
     2  Exp* e;
     3  
     4  int
     5  main (void)
     6  {
     7    delete e;
     8  }

Triggers an error with 3.2, but a warning with both 3.3 and 3.4.  The warning
is:

/tmp % g++-3.2 -Wall foo.cc; echo STATUS: $?                     nostromo 17:49
foo.cc: In function `int main()':
foo.cc:2: `e' has incomplete type
foo.cc:1: forward declaration of `struct Exp'
STATUS: 1
/tmp % g++-3.3 -Wall foo.cc; echo STATUS: $?                     nostromo 17:50
foo.cc: In function `int main()':
foo.cc:2: warning: `e' has incomplete type
foo.cc:1: warning: forward declaration of `struct Exp'
STATUS: 0
/tmp % g++-3.4 -Wall foo.cc; echo STATUS: $?                     nostromo 17:50
foo.cc: In function `int main()':
foo.cc:2: AVERTISSEMENT:  e  a un type incomplet
foo.cc:1: AVERTISSEMENT: forward declaration of `struct Exp'
STATUS: 0

as you can see, the problem is that the class Exp is unknown when the
dtor is called via delete.  Nevertheless the reason for the complaints
is _never_ made explicit: it took me a while to understand that it
is the call to delete that was responsible for the warning is my Real
Life Code.  I would suggest that G++ would point to the line 7
when saying ``e' has incomplete type' instead of pointing to the
declaration of `e' (or its declaration could be added, but the current
way seem to be complaining that `e's declaration is incomplete!).

Thanks for all the good work!

Environment:
System: Linux nostromo 2.4.22 #1 SMP mer sep 17 19:49:48 CEST 2003 i686 GNU/Linux
Architecture: i686

	
host: i486-pc-linux-gnu
build: i486-pc-linux-gnu
target: i486-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux

How-To-Repeat:
Compile the sample above.
------- Additional Comments From akim at epita dot fr  2003-11-17 16:58 -------
Fix:
See above.

-- 
           Summary: warning: `e' has incomplete type without location
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: akim at epita dot fr
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i486-pc-linux-gnu
  GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu


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


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