WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED INVALID
17809
Overload String::operator[] for integer types other than unsigned
https://bugs.webkit.org/show_bug.cgi?id=17809
Summary
Overload String::operator[] for integer types other than unsigned
Mark Mentovai
Reported
2008-03-12 14:33:37 PDT
I've found that using operator[ to subscript a String in EditorCommand.cpp fails, the compiler giving the following error: .../WebKit/WebCore/editing/EditorCommand.cpp: In function ‘bool WebCore::executeFormatBlock(WebCore::Frame*, WebCore::Event*, WebCore::EditorCommandSource, const WebCore::String&)’: .../WebKit/WebCore/editing/EditorCommand.cpp:387: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: .../WebKit/WebCore/platform/text/PlatformString.h:72: note: candidate 1: UChar WebCore::String::operator[](unsigned int) const .../WebKit/WebCore/editing/EditorCommand.cpp:387: note: candidate 2: operator[](NSString*, int) <built-in> To resolve the ambiguity, I've used 0U instead of 0 to subscript the String in question.
Attachments
Use 0U instead of 0
(1.15 KB, patch)
2008-03-12 14:35 PDT
,
Mark Mentovai
darin
: review-
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Mark Mentovai
Comment 1
2008-03-12 14:35:25 PDT
Created
attachment 19714
[details]
Use 0U instead of 0
Eric Seidel (no email)
Comment 2
2008-03-12 15:11:18 PDT
Ick. I hope there is some other way to avoid this error.
Darin Adler
Comment 3
2008-03-13 09:44:18 PDT
Comment on
attachment 19714
[details]
Use 0U instead of 0 This should only be an issue in Objective-C++ files. The ambiguity comes from the operator NSString*() overload. Why are you seeing this ambiguity in a .cpp file? Are you trying to compile this file as ObjC++?
Darin Adler
Comment 4
2008-03-13 09:45:40 PDT
Comment on
attachment 19714
[details]
Use 0U instead of 0 I'm going to mark this as review-. The real problem is that this file is being compiled with __OBJC__ defined -- you need to figure out why.
Darin Adler
Comment 5
2008-03-13 09:47:34 PDT
Aside from the specific issues in this .cpp file, we can eliminate this ambiguity in ObjC++ files by overloading the String [] operator for integer types other than unsigned. But once we overload for any type other than unsigned, we'll need overloads for all the integer types we want to allow. Doing that overload would be nice for ObjC++ files -- should not be relevant for this file, though.
Mark Mentovai
Comment 6
2008-03-13 11:38:07 PDT
Good catch, this file somehow got flipped to sourcecode.cpp.objcpp in my project. I've got a few other filetype things that I've verified do exist in the trunk WebCore.xcodeproj, I'll file separately for those, leaving this bug to be repurposed per
comment 5
if desired.
Mark Mentovai
Comment 7
2008-03-13 13:09:07 PDT
Filetype cleanup mentioned in
comment 6
is
bug 17833
.
Mark Mentovai
Comment 8
2008-03-14 12:11:29 PDT
I found other uses of 0U to disambiguate between the two choices for operator[] in platform/graphics/mac/IconMac.mm and platform/mac/KeyEvent.mm.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug