title: gcc 4.9.2 bug in -Werror=sizeof-pointer-memaccess?
body: <pre><code>#include &lt;string.h&gt;
  
  void test(char charArray [100])
  {
      strncpy(charArray, "some text", sizeof(charArray));
  }
  
  int main()
  {
      char charArray [100];
      test(charArray);
      // EDIT: According to comment from P0W I added this line - where is the difference?
      strncpy(charArray, "some text", sizeof(charArray)); // compiles OK
  }
  </code></pre>
  
  <p>Compiled with gcc 4.9.2 on SLES 11 SP2 with this command line <code>g++ gcc-warning-bug-2.cpp -Wall -Wextra -c -Werror</code> I get this warning. Due the <code>-Werror</code> flag I cannot compile the project:</p>
  
  <pre><code>gcc-warning-bug-2.cpp: In function ‘void test(char*)’:
  gcc-warning-bug-2.cpp:5:40: error: argument to ‘sizeof’ in ‘char* strncpy(char*, const char*, size_t)’ call is the same expression as the destination; did you mean to provide an explicit length? [-Werror=sizeof-pointer-memaccess]
    strncpy(charArray, "some text", sizeof(charArray));
                                          ^
  cc1plus: all warnings being treated as errors
  </code></pre>
  
  <p>According to the actual gcc 4.9.2 documentation <a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html" rel="nofollow">https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html</a></p>
  
  <pre><code>-Wsizeof-pointer-memaccess
  Warn for suspicious length parameters to certain string and memory built-in functions if the argument uses sizeof.
  This warning warns e.g. about memset (ptr, 0, sizeof (ptr)); if ptr is not an array, but a pointer, and suggests a possible fix, or about memcpy (&amp;foo, ptr, sizeof (&amp;foo));. This warning is enabled by -Wall.
  </code></pre>
  
  <p>this should be compiled fine because <code>charArray</code> is an array!</p>
  
  <p>Bug? Should I report it to GNU gcc developer team?</p>