Closed Bug 396710 Opened 17 years ago Closed 17 years ago

Compiling nsAppShell.mm results in cast error

Categories

(Core :: Widget: Cocoa, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: Mardak, Assigned: Mardak)

Details

Attachments

(1 file, 1 obsolete file)

The following line has an error about not being able to cast const NSA* to NSA*.
+  NSAutoreleasePool* pool = static_cast<const NSAutoreleasePool*>

Probably introduced by bug 348748
http://hg.mozilla.org/cvs-trunk-mirror/?diff/ab58bdbde9e0/widget/src/cocoa/nsAppShell.mm

Changing pool to type const NSAutoreleasePool * seems to compile even with the "[pool release];" below.

I just switched over to gcc4 instead of gcc3.3 last night and ran into this issue.
Attached patch v1 (obsolete) — Splinter Review
Attachment #281480 - Flags: review?
Attachment #281480 - Flags: review? → review?(smichaud)
Actually I'd prefer to fix the problem this way:

-  NSAutoreleasePool* pool = static_cast<const NSAutoreleasePool*>
+  NSAutoreleasePool* pool = static_cast<NSAutoreleasePool*>
                                        (::CFArrayGetValueAtIndex(mAutoreleasePools,
                                                                  count - 1));

As far as I can tell, there's no reason to use "const" in the cast.
(In reply to comment #2)
> As far as I can tell, there's no reason to use "const" in the cast.

widget/src/cocoa/nsAppShell.mm:399: error: static_cast from type 'const void*' to type 'NSAutoreleasePool*' casts away constness
Comment on attachment 281480 [details] [diff] [review]
v1

> widget/src/cocoa/nsAppShell.mm:399: error: static_cast from type 'const void*'
> to type 'NSAutoreleasePool*' casts away constness

Oh, well.

Then your patch looks fine to me as it stands ... though I haven't
tested it myself.
Attachment #281480 - Flags: review?(smichaud) → review+
Comment on attachment 281480 [details] [diff] [review]
v1

The indentation on the continuation lines is starting to look heinous here.  Please fix.
Attached patch v1.1Splinter Review
Combined the 2nd and 3rd line and shifted indent left.. which makes it line up nicely with the 4th.

But I wonder why other people aren't running into this compilation error.. ?
Assignee: joshmoz → edilee
Attachment #281480 - Attachment is obsolete: true
Status: NEW → ASSIGNED
> But I wonder why other people aren't running into this compilation
> error.. ?

What results do you get from running gcc_select?

If it returns '3.3' (or anything but '4.0'), try switching to '4.0'
(you'll need to use sudo).
I actually got the error switching /to/ 4.0. I am using a PowerPC iBook though.

$ gcc-3.3 -v
Reading specs from /usr/libexec/gcc/darwin/ppc/3.3/specs
Thread model: posix
gcc version 3.3 20030304 (Apple Computer, Inc. build 1809)

$ gcc-4.0 -v
Using built-in specs.
Target: powerpc-apple-darwin8
Configured with: /private/var/tmp/gcc/gcc-5026.obj~19/src/configure --disable-checking --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^+.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/gcc/darwin/4.0/c++ --build=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 --target=powerpc-apple-darwin8
Thread model: posix
gcc version 4.0.0 (Apple Computer, Inc. build 5026)
I'm stumped.

The only other thing I can suggest is that you need to rebuild from
scratch whenever you switch gcc versions.

Your developer tools seem a bit old, though -- my gcc 4 version is
actually 4.0.1 (and the build number is 5250).

(By the way I build on both PPC and Intel (using gcc 4.0.1 in both
cases), and I've never seen a cast _error_ ... though I might have
missed a warning.)
Comment on attachment 281902 [details] [diff] [review]
v1.1

Do we want this for 1.9?

I downloaded the latest Xcode which updated g++ to 4.0.1 build 5367, and I don't get the cast error even without this patch.
Attachment #281902 - Flags: superreview?(roc)
Comment on attachment 281902 [details] [diff] [review]
v1.1

might as well have this
Attachment #281902 - Flags: superreview?(roc)
Attachment #281902 - Flags: superreview+
Attachment #281902 - Flags: approval1.9+
Checking in widget/src/cocoa/nsAppShell.mm;
/cvsroot/mozilla/widget/src/cocoa/nsAppShell.mm,v  <--  nsAppShell.mm
new revision: 1.24; previous revision: 1.23
done
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: