<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>17809</bug_id>
          
          <creation_ts>2008-03-12 14:33:37 -0700</creation_ts>
          <short_desc>Overload String::operator[] for integer types other than unsigned</short_desc>
          <delta_ts>2009-03-17 14:20:06 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Trivial</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Mark Mentovai">mark</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>darin</cc>
    
    <cc>mjs</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>73516</commentid>
    <comment_count>0</comment_count>
    <who name="Mark Mentovai">mark</who>
    <bug_when>2008-03-12 14:33:37 -0700</bug_when>
    <thetext>I&apos;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&amp;)’:
.../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) &lt;built-in&gt;

To resolve the ambiguity, I&apos;ve used 0U instead of 0 to subscript the String in question.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73517</commentid>
    <comment_count>1</comment_count>
      <attachid>19714</attachid>
    <who name="Mark Mentovai">mark</who>
    <bug_when>2008-03-12 14:35:25 -0700</bug_when>
    <thetext>Created attachment 19714
Use 0U instead of 0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73525</commentid>
    <comment_count>2</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2008-03-12 15:11:18 -0700</bug_when>
    <thetext>Ick.  I hope there is some other way to avoid this error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73577</commentid>
    <comment_count>3</comment_count>
      <attachid>19714</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2008-03-13 09:44:18 -0700</bug_when>
    <thetext>Comment on attachment 19714
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++?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73578</commentid>
    <comment_count>4</comment_count>
      <attachid>19714</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2008-03-13 09:45:40 -0700</bug_when>
    <thetext>Comment on attachment 19714
Use 0U instead of 0

I&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73579</commentid>
    <comment_count>5</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2008-03-13 09:47:34 -0700</bug_when>
    <thetext>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&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73610</commentid>
    <comment_count>6</comment_count>
    <who name="Mark Mentovai">mark</who>
    <bug_when>2008-03-13 11:38:07 -0700</bug_when>
    <thetext>Good catch, this file somehow got flipped to sourcecode.cpp.objcpp in my project.  I&apos;ve got a few other filetype things that I&apos;ve verified do exist in the trunk WebCore.xcodeproj, I&apos;ll file separately for those, leaving this bug to be repurposed per comment 5 if desired.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73623</commentid>
    <comment_count>7</comment_count>
    <who name="Mark Mentovai">mark</who>
    <bug_when>2008-03-13 13:09:07 -0700</bug_when>
    <thetext>Filetype cleanup mentioned in comment 6 is bug 17833.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73758</commentid>
    <comment_count>8</comment_count>
    <who name="Mark Mentovai">mark</who>
    <bug_when>2008-03-14 12:11:29 -0700</bug_when>
    <thetext>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.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>19714</attachid>
            <date>2008-03-12 14:35:25 -0700</date>
            <delta_ts>2008-03-13 13:08:44 -0700</delta_ts>
            <desc>Use 0U instead of 0</desc>
            <filename>webkit-17809.1.patch</filename>
            <type>text/plain</type>
            <size>1175</size>
            <attacher name="Mark Mentovai">mark</attacher>
            
              <data encoding="base64">SW5kZXg6IENoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBDaGFuZ2VMb2cJKHJldmlzaW9uIDMxMDA1
KQorKysgQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBAIC0xLDMgKzEsMTEgQEAKKzIwMDgtMDMt
MTIg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lmICh0YWdOYW1lWzBVXSA9PSAnPCcgJiYgdGFnTmFtZVt0
YWdOYW1lLmxlbmd0aCgpIC0gMV0gPT0gJz4nKQogICAgICAgICB0YWdOYW1lID0gdGFnTmFtZS5z
dWJzdHJpbmcoMSwgdGFnTmFtZS5sZW5ndGgoKSAtIDIpOwogICAgIGlmICghdmFsaWRCbG9ja1Rh
Zyh0YWdOYW1lKSkKICAgICAgICAgcmV0dXJuIGZhbHNlOwo=
</data>
<flag name="review"
          id="8633"
          type_id="1"
          status="-"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>