Re: GCC flaw in FreeBSD5? Cone 0.58 does not compile (was: [cone] Cone 0.58 released.)

From: Jacques A. Vidrine <nectar_at_FreeBSD.org>
Date: Sat, 17 Apr 2004 09:17:54 -0500
On Fri, Apr 16, 2004 at 05:30:13PM +0200, Matthias Andree wrote:
> 0.58 - without any patches - does not compile on FreeBSD 5-CURRENT:
> 
> gmake[2]: Entering directory `/tmp/root/ports/mail/cone/work/cone-0.58/libmail'
> gmake  all-am
> gmake[3]: Entering directory `/tmp/root/ports/mail/cone/work/cone-0.58/libmail'
> Compiling mbox.C
> mbox.C: In member function `bool mail::mbox::scan(mail::file&, mail::file*, 
>    bool, std::set<std::string, std::less<std::string>, 
>    std::allocator<std::string> >*, bool, mail::callback*)':
> mbox.C:1246: error: base operand of `->' has non-pointer type `mail::file'
> mbox.C:1283: error: base operand of `->' has non-pointer type `mail::file'
> gmake[3]: *** [mbox.o] Error 1
> gmake[3]: Leaving directory `/tmp/root/ports/mail/cone/work/cone-0.58/libmail'
> gmake[2]: *** [all] Error 2
> 
> The code looks fine and compiles fine on SuSE Linux 8.2 with an updated
> vanilla GCC 3.3.3. Given that mail::file has an operator FILE *() that
> returns the FILE* pointer, I don't see what the compiler wants to tell
> me. Cc:'ing FreeBSD-current.
> 
> > 1149  bool mail::mbox::scan(mail::file &scanFile,
> > 1150                        mail::file *saveFile,
> ...
>   1243                                  // Remember how big the saveFile was,
>   1244                                  // originally.
>   1245  
> > 1246                                  if (fstat(fileno(*saveFile), &stat_buf) < 0)
>   1247                                  {
>   1248                                          return false;
>   1249                                  }
>   1250  
> ...
>   1280                          {
>   1281                                  // Potential short cut.
>   1282  
> > 1283                                  if (fstat(fileno(scanFile), &stat_buf) < 0)
>   1284                                  {
>   1285                                          return false;
>   1286                                  }
>   1287  
> 
> 
> -bash-2.05b# gmake --version
> GNU Make 3.80
> 
> -bash-2.05b# gcc --version (g++ is the same version, I checked)
> gcc (GCC) 3.3.3 [FreeBSD] 20031106
> 
> Config.log is attached.


`fileno' may be implemented as a macro (as it is on FreeBSD), so one
cannot rely on implicit conversions.  The invocations MUST be

   fileno((FILE *)(*saveFile))

Or better yet, the implicit conversions should be removed and replaced
by an explicit operation, e.g. `fileno(saveFile->fp())'.  See the
rationale for the std::string c_str() function for more reasons why
implicit conversions are dangerous and should be avoided.

Cheers,
-- 
Jacques Vidrine / nectar_at_celabo.org / jvidrine_at_verio.net / nectar_at_freebsd.org
Received on Sat Apr 17 2004 - 05:17:55 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:51 UTC