<?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>69669</bug_id>
          
          <creation_ts>2011-10-07 14:27:09 -0700</creation_ts>
          <short_desc>WebKit2/Shared/APIClient.h complains that array subscript is below array bounds</short_desc>
          <delta_ts>2014-02-05 10:51:12 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit2</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Rafael Brandao">rafael.lobo</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>kling</cc>
    
    <cc>menard</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>480314</commentid>
    <comment_count>0</comment_count>
    <who name="Rafael Brandao">rafael.lobo</who>
    <bug_when>2011-10-07 14:27:09 -0700</bug_when>
    <thetext>I&apos;m getting the following warning trying to build WebKit2 (compiling Source/WebKit2/UIProcess/WebContext.cpp):

cc1plus: warnings being treated as errors
../../../Source/WebKit2/Shared/APIClient.h: In member function &apos;void WebKit::WebContext::initializeInjectedBundleClient(const WKContextInjectedBundleClient*)&apos;:
../../../Source/WebKit2/Shared/APIClient.h:52:13: error: array subscript is below array bounds

I&apos;m using openSUSE 11.4 (x86_64) and g++ (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]. I wonder if someone else have the same problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>480345</commentid>
    <comment_count>1</comment_count>
      <attachid>110225</attachid>
    <who name="Rafael Brandao">rafael.lobo</who>
    <bug_when>2011-10-07 15:22:01 -0700</bug_when>
    <thetext>Created attachment 110225
Just ignored the warning on APIClient</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>480371</commentid>
    <comment_count>2</comment_count>
      <attachid>110225</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2011-10-07 16:26:07 -0700</bug_when>
    <thetext>Comment on attachment 110225
Just ignored the warning on APIClient

View in context: https://bugs.webkit.org/attachment.cgi?id=110225&amp;action=review

Could you be more specific about what the warning is? Maybe it’s fixable instead of something we need to turn off.

&gt; Source/WebKit2/Shared/APIClient.h:40
&gt; +#pragma GCC diagnostic ignored &quot;-Warray-bounds&quot;

I don’t think this is the best practice for using a compiler-specific pragma. In the past we have used #if around them.

&gt; Source/WebKit2/Shared/APIClient.h:55
&gt; +#pragma GCC diagnostic warning &quot;-Warray-bounds&quot;

It’s not good to unconditionally turn a warning on even if it wasn’t on before; instead you should use push/pop.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>482365</commentid>
    <comment_count>3</comment_count>
      <attachid>110674</attachid>
    <who name="Rafael Brandao">rafael.lobo</who>
    <bug_when>2011-10-12 05:45:22 -0700</bug_when>
    <thetext>Created attachment 110674
Added a check for non-negative value for array&apos;s index

I&apos;ve googled a bit about this warning and I&apos;ve found out that sometimes the compiler make some optimizations on the code and the access on arrays may be negative values after these changes (sources: http://www.mail-archive.com/gcc@gcc.gnu.org/msg46397.html and http://gcc.gnu.org/ml/gcc/2009-09/msg00270.html). So I&apos;ve just added a check for non-negative values for that index and it has stopped complaining. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>483318</commentid>
    <comment_count>4</comment_count>
      <attachid>110674</attachid>
    <who name="Alexis Menard (darktears)">menard</who>
    <bug_when>2011-10-13 11:03:42 -0700</bug_when>
    <thetext>Comment on attachment 110674
Added a check for non-negative value for array&apos;s index

View in context: https://bugs.webkit.org/attachment.cgi?id=110674&amp;action=review

&gt; Source/WebKit2/Shared/APIClient.h:51
&gt; +        if (client &amp;&amp; client-&gt;version &lt; currentVersion &amp;&amp; client-&gt;version &gt;= 0)

Can currentVersion be a unsigned?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>483331</commentid>
    <comment_count>5</comment_count>
    <who name="Alexis Menard (darktears)">menard</who>
    <bug_when>2011-10-13 11:14:26 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; (From update of attachment 110674 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=110674&amp;action=review
&gt; 
&gt; &gt; Source/WebKit2/Shared/APIClient.h:51
&gt; &gt; +        if (client &amp;&amp; client-&gt;version &lt; currentVersion &amp;&amp; client-&gt;version &gt;= 0)
&gt; 
&gt; Can currentVersion be a unsigned?

And client-&gt;version obviously. Not sure if that&apos;s possible but it looks like it could be a better fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>483349</commentid>
    <comment_count>6</comment_count>
    <who name="Rafael Brandao">rafael.lobo</who>
    <bug_when>2011-10-13 11:44:45 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; (From update of attachment 110674 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=110674&amp;action=review
&gt; 
&gt; &gt; Source/WebKit2/Shared/APIClient.h:51
&gt; &gt; +        if (client &amp;&amp; client-&gt;version &lt; currentVersion &amp;&amp; client-&gt;version &gt;= 0)
&gt; 
&gt; Can currentVersion be a unsigned?

I&apos;ve tried to change it to be unsigned, but then the compiler started to complain about comparison of unsigned expression &lt; 0 being always false. The expression it is talking about is &quot;client-&gt;version &lt; currentVersion&quot; when currentVersion is 0 which is possible. So I would just get into another warning.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>976822</commentid>
    <comment_count>7</comment_count>
      <attachid>110674</attachid>
    <who name="Anders Carlsson">andersca</who>
    <bug_when>2014-02-05 10:51:12 -0800</bug_when>
    <thetext>Comment on attachment 110674
Added a check for non-negative value for array&apos;s index

Clearing review flag on patches from before 2014. If this patch is still relevant, please reset the r? flag.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>110225</attachid>
            <date>2011-10-07 15:22:01 -0700</date>
            <delta_ts>2011-10-12 05:45:22 -0700</delta_ts>
            <desc>Just ignored the warning on APIClient</desc>
            <filename>warning.diff</filename>
            <type>text/plain</type>
            <size>1491</size>
            <attacher name="Rafael Brandao">rafael.lobo</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJLaXQyL0NoYW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQyL0No
YW5nZUxvZwppbmRleCAzNGRiNmZiLi5lMTlhMWY0IDEwMDY0NAotLS0gYS9Tb3VyY2UvV2ViS2l0
Mi9DaGFuZ2VMb2cKKysrIGIvU291cmNlL1dlYktpdDIvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTUg
QEAKKzIwMTEtMTAtMDcgIFJhZmFlbCBCcmFuZGFvICA8cmFmYWVsLmxvYm9Ab3BlbmJvc3NhLm9y
Zz4KKworICAgICAgICBEaXNhYmxlIHdhcm5pbmcgKGFycmF5IGJvdW5kcykgb24gV2ViS2l0MiBB
UElDbGllbnQKKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lk
PTY5NjY5CisKKyAgICAgICAgQWRkZWQgYW4gZXhjZXB0aW9uIHRvIEFQSUNsaWVudCwgc28gaXQg
d2lsbCBpZ25vcmUgYXJyYXkKKyAgICAgICAgYm91bmRzIHdhcm5pbmcgYXJvdW5kIGl0cyBmdW5j
dGlvbiBjYWxsZWQgJ2luaXRpYWxpemUnLgorCisgICAgICAgIFJldmlld2V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WVudFRyYWl0czxDbGllbnRJbnRlcmZhY2U+OjppbnRlcmZhY2VTaXplc0J5VmVyc2lvbltj
bGllbnQtPnZlcnNpb25dKTsKICAgICB9CisjcHJhZ21hIEdDQyBkaWFnbm9zdGljIHdhcm5pbmcg
Ii1XYXJyYXktYm91bmRzIgogICAgIAogcHJvdGVjdGVkOgogICAgIENsaWVudEludGVyZmFjZSBt
X2NsaWVudDsK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>110674</attachid>
            <date>2011-10-12 05:45:22 -0700</date>
            <delta_ts>2014-02-05 10:51:12 -0800</delta_ts>
            <desc>Added a check for non-negative value for array&apos;s index</desc>
            <filename>fix-warning-below-array-bounds.diff</filename>
            <type>text/plain</type>
            <size>1189</size>
            <attacher name="Rafael Brandao">rafael.lobo</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJLaXQyL0NoYW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQyL0No
YW5nZUxvZwppbmRleCAzNGRiNmZiLi40MzJiZGExIDEwMDY0NAotLS0gYS9Tb3VyY2UvV2ViS2l0
Mi9DaGFuZ2VMb2cKKysrIGIvU291cmNlL1dlYktpdDIvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTUg
QEAKKzIwMTEtMTAtMTIgIFJhZmFlbCBCcmFuZGFvICA8cmFmYWVsLmxvYm9Ab3BlbmJvc3NhLm9y
Zz4KKworICAgICAgICBBdm9pZCB3YXJuaW5nIChiZWxvdyBhcnJheSBib3VuZHMpIG9uIFdlYktp
dDIgQVBJQ2xpZW50CisgICAgICAgIGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNn
aT9pZD02OTY2OQorCisgICAgICAgIEZvcmNlcyBjb21waWxlciB0byBpZGVudGlmeSB0aGUgYXJy
YXkncyBpbmRleCBhcyBhIG5vbi1uZWdhdGl2ZSB2YWx1ZS4KKworICAgICAgICBSZXZpZXdlZCBi
eSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICAqIFNoYXJlZC9BUElDbGllbnQuaDoKKyAgICAg
ICAgKFdlYktpdDo6QVBJQ2xpZW50Ojppbml0aWFsaXplKToKKwogMjAxMS0xMC0wNyAgU2hlcmlm
ZiBCb3QgIDx3ZWJraXQucmV2aWV3LmJvdEBnbWFpbC5jb20+CiAKICAgICAgICAgVW5yZXZpZXdl
ZCwgcm9sbGluZyBvdXQgcjk2OTM4LgpkaWZmIC0tZ2l0IGEvU291cmNlL1dlYktpdDIvU2hhcmVk
L0FQSUNsaWVudC5oIGIvU291cmNlL1dlYktpdDIvU2hhcmVkL0FQSUNsaWVudC5oCmluZGV4IGJl
NmVmM2EuLjcxMmEzOTEgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XZWJLaXQyL1NoYXJlZC9BUElDbGll
bnQuaAorKysgYi9Tb3VyY2UvV2ViS2l0Mi9TaGFyZWQvQVBJQ2xpZW50LmgKQEAgLTQ4LDcgKzQ4
LDcgQEAgcHVibGljOgogCiAgICAgICAgIG1lbXNldCgmbV9jbGllbnQsIDAsIHNpemVvZihtX2Ns
aWVudCkpOwogCi0gICAgICAgIGlmIChjbGllbnQgJiYgY2xpZW50LT52ZXJzaW9uIDwgY3VycmVu
dFZlcnNpb24pCisgICAgICAgIGlmIChjbGllbnQgJiYgY2xpZW50LT52ZXJzaW9uIDwgY3VycmVu
dFZlcnNpb24gJiYgY2xpZW50LT52ZXJzaW9uID49IDApCiAgICAgICAgICAgICBtZW1jcHkoJm1f
Y2xpZW50LCBjbGllbnQsIEFQSUNsaWVudFRyYWl0czxDbGllbnRJbnRlcmZhY2U+OjppbnRlcmZh
Y2VTaXplc0J5VmVyc2lvbltjbGllbnQtPnZlcnNpb25dKTsKICAgICB9CiAgICAgCg==
</data>

          </attachment>
      

    </bug>

</bugzilla>