>Submitter-Id:  net
>Originator:    Akim Demaille
>Organization:  
>Confidential:  no
>Synopsis:      warning: `e' has incomplete type without location
>Severity:      
>Priority:      
>Category:      c++
>Class:         
>Release:       3.3.2 (Debian) (Debian testing/unstable)
>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
>Description:
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!

>How-To-Repeat:
Compile the sample above.
>Fix:
See above.


Reply via email to