Closed Bug 280479 Opened 20 years ago Closed 19 years ago

Compiling from CVS fails with gcc-4.0.0 when nsStandardURL.cpp:494 accesses protected copy constructor of nsCSubstring from nsTSubstring.h:502

Categories

(Core :: XPCOM, defect)

PowerPC
macOS
defect
Not set
blocker

Tracking

()

RESOLVED INVALID

People

(Reporter: jfrank, Unassigned)

References

Details

User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8a6) Gecko/20050111
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8a6) Gecko/20050111

When trying to compile from CVS with gcc-4.0.0, I get the following error every
time:
/Users/jordan/Projects/mozilla/netwerk/base/src/nsStandardURL.cpp: In member
function `nsresult nsStandardURL::BuildNormalizedSpec(const char*)':
../../../dist/include/string/nsTSubstring.h:502: error:
'nsCSubstring::nsCSubstring(const nsCSubstring&)' is protected
/Users/jordan/Projects/mozilla/netwerk/base/src/nsStandardURL.cpp:494: error:
within this context
../../../dist/include/string/nsTSubstring.h:502: error:
'nsCSubstring::nsCSubstring(const nsCSubstring&)' is protected
/Users/jordan/Projects/mozilla/netwerk/base/src/nsStandardURL.cpp:494: error:
within this context
make[5]: *** [nsStandardURL.o] Error 1
make[4]: *** [libs] Error 2
make[3]: *** [libs] Error 2
make[2]: *** [tier_9] Error 2
gnumake[1]: *** [default] Error 2
gnumake: *** [build] Error 2

I don't know if this is a gcc-4.0.0 problem, but in nsTSubstring.h we have
        // copy-constructor, constructs as dependent on given object
        // (NOTE: this is for internal use only)
        nsTSubstring_CharT( const self_type& str )
and this lies in the protected: section. Then in nsStandardURL.cpp:494 we have
        const nsCSubstring& tempHost =
            Substring(spec + mHost.mPos, spec + mHost.mPos + mHost.mLen);
so it would seem that the copy constructor is being called externally. I'm not
much of a C++ coder though, so I don't know how this should all work.

Reproducible: Always

Steps to Reproduce:
1. gnumake -f client.mk checkout
2. gnumake -f client.mk build

Actual Results:  
...
nsStandardURL.cpp
c++ -o nsStandardURL.o -c  -DOSTYPE=\"Darwin7.7.0\" -DOSARCH=\"Darwin\" 
-I../../../dist/include/xpcom -I../../../dist/include/string
-I../../../dist/include/mimetype -I../../../dist/include/uconv
-I../../../dist/include/locale -I../../../dist/include/pref
-I../../../dist/include/necko -I../../../dist/include
-I/Users/jordan/Projects/mozilla/obj-powerpc-apple-darwin7.7.0/dist/include/nspr
       -mdynamic-no-pic   -fno-rtti -fno-exceptions -Wall -Wconversion
-Wpointer-arith -Wcast-align -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy
-Wno-non-virtual-dtor -Wno-long-long -I//usr/include -fpascal-strings
-no-cpp-precomp -fno-common -fshort-wchar -I//Developer/Headers/FlatCarbon -pipe
 -DNDEBUG -DTRIMMED -O3 -faltivec -maltivec -mabi=altivec -fomit-frame-pointer
-mcpu=7450 -mtune=7450 -mpowerpc -mpowerpc-gfxopt   -DMOZILLA_CLIENT -include
../../../mozilla-config.h -Wp,-MD,.deps/nsStandardURL.pp
/Users/jordan/Projects/mozilla/netwerk/base/src/nsStandardURL.cpp
/Users/jordan/Projects/mozilla/netwerk/base/src/nsStandardURL.cpp: In member
function `nsresult nsStandardURL::BuildNormalizedSpec(const char*)':
../../../dist/include/string/nsTSubstring.h:502: error:
'nsCSubstring::nsCSubstring(const nsCSubstring&)' is protected
/Users/jordan/Projects/mozilla/netwerk/base/src/nsStandardURL.cpp:494: error:
within this context
../../../dist/include/string/nsTSubstring.h:502: error:
'nsCSubstring::nsCSubstring(const nsCSubstring&)' is protected
/Users/jordan/Projects/mozilla/netwerk/base/src/nsStandardURL.cpp:494: error:
within this context
make[5]: *** [nsStandardURL.o] Error 1
make[4]: *** [libs] Error 2
make[3]: *** [libs] Error 2
make[2]: *** [tier_9] Error 2
gnumake[1]: *** [default] Error 2
gnumake: *** [build] Error 2


Expected Results:  
Should have compiled properly.

contents of my .mozconfig
# Options for client.mk.
mk_add_options MOZ_CO_PROJECT=browser,mail,calendar,xulrunner,macbrowser
mk_add_options MOZ_CO_MODULE=mozilla/other-licenses/libart_lgpl
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@
mk_add_options GLIB_CONFIG="/usr/bin/pkg-config glib-2.0"
mk_add_options LIBIDL_CONFIG="/usr/bin/pkg-config libIDL-2.0"

# Options for 'configure' (same as command-line options).
ac_add_options --with-macos-sdk=/
ac_add_options
--with-java-include-path=/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home/include
ac_add_options
--with-java-bin-path=/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home/bin/
ac_add_options --with-pthreads
ac_add_options --enable-macos-target=10.3
ac_add_options --enable-default-toolkit=mac
ac_add_options --with-qtdir=/Developer/qt-mac-free-3.3.3
#ac_add_options --enable-application=browser
ac_add_options --enable-application=mail
#ac_add_options --enable-application=calendar
#ac_add_options --enable-application=macbrowser
ac_add_options --enable-calendar
ac_add_options --enable-official-branding
ac_add_options --enable-pango
ac_add_options --enable-svg
ac_add_options --enable-svg-renderer-libart
ac_add_options --disable-tests
ac_add_options --enable-optimize="-O3 -faltivec -maltivec -mabi=altivec
-fomit-frame-pointer -mcpu=7450 -mtune=7450 -mpowerpc -mpowerpc-gfxopt"
ac_add_options --enable-strip
ac_add_options --enable-strip-libs
ac_add_options --enable-prebinding
ac_add_options --enable-xterm-updates
ac_add_options --disable-shared
ac_add_options --enable-static
ac_add_options --disable-debug 
ac_add_options --without-system-nspr
ac_add_options --without-system-zlib
ac_add_options --without-system-jpeg
ac_add_options --without-system-png
ac_add_options --without-system-mng


contents of client.mk
Probably also of some importance is the version of gcc being used:
jordan@Bernie mozilla % gcc --version
powerpc-apple-darwin7-gcc-4.0.0 (GCC) 4.0.0 20041026 (Apple Computer, Inc. build
4037)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Flags: blocking1.8b+
Jordan,

You you set the blocking flag to "?" if you want Drivers to consider this bug
for Blocking 1.8b.
Flags: blocking1.8b+
So... the line:

 const nsCSubstring& tempHost =
        Substring(spec + mHost.mPos, spec + mHost.mPos + mHost.mLen);

should NOT be calling any nsCSubstring copy constructors that I can see.  It
should be calling an nsTDependentSubstring_CharT constructor, then holding a
reference to the resulting value (which happens to inherit from nsCSubstring, so
holding an |nsCSubstring&| is ok).

Sounds like a bug in the particular GCC version being used here....
It'd be interesting to see what happens if the copy-ctor is actually made
public.  Does the compiler generate code to call it, or is it only trying to
verify that it could perform the type conversion?  I wonder if there is some
subtlety of the C++ language at play here.
There's an annoying case in the C++ standard where it says that
copy-constructors must be accessible even if they're not going to be used, and
the compiler has the option of using them.  This may be it.
I moved the copy constructor into the public: section, it seemed to work. it
died for the same reason on nsTAString.h or something like that, so I moved that
copy constructor into the public: section as well. Now it gets past that part,
and is dying soon after with the error:

/Users/jordan/Projects/mozilla/gfx/src/mac/nsDeviceContextMac.cpp: In static
member function `static bool nsDeviceContextMac::GetMacFontNumber(const
nsString&, short int&)':
/Users/jordan/Projects/mozilla/gfx/src/mac/nsDeviceContextMac.cpp:918: error:
cast from 'void*' to 'short int' loses precision
/Users/jordan/Projects/mozilla/gfx/src/mac/nsDeviceContextMac.cpp: In function
`PRBool EnumerateFont(nsHashKey*, void*, void*)':
/Users/jordan/Projects/mozilla/gfx/src/mac/nsDeviceContextMac.cpp:1119: error:
cast from 'void*' to 'FMFontFamily' loses precision
make[5]: *** [nsDeviceContextMac.o] Error 1
make[4]: *** [libs] Error 2
make[3]: *** [libs] Error 2
make[2]: *** [tier_9] Error 2
gnumake[1]: *** [default] Error 2
gnumake: *** [build] Error 2


again, the version of gcc is:
powerpc-apple-darwin7-gcc-4.0.0 (GCC) 4.0.0 20041026 (Apple Computer, Inc. build
4043)


and just for the heck of it, the output of uname -a is:
Darwin Bernie.local 7.7.0 Darwin Kernel Version 7.7.0: Sun Nov  7 16:06:51 PST
2004; root:xnu/xnu-517.9.5.obj~1/RELEASE_PPC  Power Macintosh powerpc

let me know how I can help...
Jordan Frank, can you please attach the patch you used to get past the first error?
Status: UNCONFIRMED → NEW
Ever confirmed: true
--- nsTSubstring.h      2005-03-14 10:46:50 -0800
+++ nsTSubstring.h.new  2005-02-17 10:22:12 -0800
@@ -461,6 +461,16 @@
           mFlags(flags) {}
 #endif
 
+        // copy-constructor, constructs as dependent on given object
+        // (NOTE: this is for internal use only)
+      nsTSubstring_CharT( const self_type& str )
+#ifdef MOZ_V1_STRING_ABI
+        : abstract_string_type(str.mData, str.mLength, str.mFlags &
(F_TERMINATED | F_VOIDED)) {}
+#else
+        : mData(str.mData),
+          mLength(str.mLength),
+          mFlags(str.mFlags & (F_TERMINATED | F_VOIDED)) {}
+#endif
 
     protected:
 
@@ -497,16 +507,6 @@
         : mFlags(flags) {}
 #endif
 
-        // copy-constructor, constructs as dependent on given object
-        // (NOTE: this is for internal use only)
-      nsTSubstring_CharT( const self_type& str )
-#ifdef MOZ_V1_STRING_ABI
-        : abstract_string_type(str.mData, str.mLength, str.mFlags &
(F_TERMINATED | F_VOIDED)) {}
-#else
-        : mData(str.mData),
-          mLength(str.mLength),
-          mFlags(str.mFlags & (F_TERMINATED | F_VOIDED)) {}
-#endif
 
         /**
          * this function releases mData and does not change the value of
Blocks: 292266
Same error for me when i compile Firefox trunk with GCC 4.0 on Mac OS 10.4.

I reported another error message, but got past that. Until this error...
https://bugzilla.mozilla.org/show_bug.cgi?id=292266
Note that bug 260402 seems to be about the same problem.
Assignee: general → string
Component: General → String
Product: Mozilla Application Suite → Core
QA Contact: general
Version: unspecified → Trunk
Is this a problem in the gcc 4.0 release, or just the prerelease that Apple
happened to ship?
This seems to be a bug in the gcc 4 that Apple ships with 10.4.0, which is based
on pre-final gcc 4.0.0, and identifies itself as:

gcc version 4.0.0 20041026 (Apple Computer, Inc. build 4061)

The current Apple gcc branch from cvs DOES NOT have this bug, and identifies
itself as:

gcc version 4.0.0 (Apple Computer, Inc. build 5016)

(You can pick this up from the gcc cvs repository, the branch is
apple-local-200502-branch.)

This is presumably much closer to gcc 4.0.0 final.  I assume that the
non-Apple-branch 4.0.0 release also does not have the bug, based on the lack of
grumbling from users of other platforms.

With build 5016, the only errors I'm seeing are about casts from void * to
narrower types.  It seems that all of these are in Mac-specific code.

Since this bug will apparently be corrected in the next gcc update from Apple,
and it's not really a Mozilla problem, I don't think it makes sense to update
Mozilla to work around the bug.  Something should be done about the casts from
void *, though.
Confirming my previous suspicion: the bug does not appear to be present in the
official April 20 release of gcc 4.0.0.
As stated above, building with GCC4 work correctly, just not with the
pre-release shipped with Mac OS X 10.4 Tiger. Marking this bug as INVALID.
Reopen if the problem occurs with the final version of GCC4.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
Component: String → XPCOM
You need to log in before you can comment on or make changes to this bug.