<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Thank you for explanation Richard!<br>
      As I see, turning 'c' into 'const int *' doesn't suppress GCC
      diagnostic. However, this is all information I need.<br>
      <br>
      19.02.2018 21:44, Richard Smith пишет:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAOfiQqmu=icDJhSgGTwz_OSBuusn7JojVzUEO3pVv8LYEQ8N8w@mail.gmail.com">
      <div dir="auto">
        <div>
          <div class="gmail_extra">
            <div class="gmail_quote">On 19 Feb 2018 10:31, "Aleksei
              Sidorin via cfe-dev" <<a
                href="mailto:cfe-dev@lists.llvm.org"
                moz-do-not-send="true">cfe-dev@lists.llvm.org</a>>
              wrote:<br type="attribution">
              <blockquote class="quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div text="#000000" bgcolor="#FFFFFF">
                  <p>Hi all,</p>
                  <p>Consider a test case:</p>
                  <div>
                    <div>
                      <div><tt>#include</tt><tt> <stdio.h></tt></div>
                      <tt><br>
                      </tt>
                      <div><tt>typedef</tt><tt> </tt><tt>int</tt><tt>
                          a[];</tt></div>
                      <tt><br>
                      </tt>
                      <div><tt>void</tt><tt> print(</tt><tt>int</tt><tt>
                          *c) {</tt></div>
                      <div><tt>   printf(</tt><tt>"%d\n"</tt><tt>, c[</tt><tt>0</tt><tt>]);</tt></div>
                      <div><tt>}</tt></div>
                      <tt><br>
                      </tt>
                      <div><tt>int</tt><tt> main() {</tt></div>
                      <div><tt>   print(a{</tt><tt>2</tt><tt>});</tt></div>
                      <div><tt>   </tt><tt>return</tt><tt> </tt><tt>0</tt><tt>;</tt></div>
                      <div><tt>}</tt></div>
                    </div>
                    <br>
                    `g++ -std=gnu++11 -fsyntax-only` fails to compile
                    this code: "error: taking address of temporary
                    array". However, clang accepts it without any
                    warnings and there is no any ASan output for it.
                    Could someone explain me if it a GCC or Clang issue?</div>
                </div>
              </blockquote>
            </div>
          </div>
        </div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">It's a GCC bug -- this code is valid. The array
          to pointer conversion is used to convert the int[1] temporary
          to a pointer; a reference is not bound to it.</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">(GCC's behaviour is not unreasonable, though,
          and perhaps we should warn on such constructs. I would imagine
          the GCC diagnostic would be suppressed by making c a pointer
          to const int?)</div>
        <div dir="auto">
          <div class="gmail_extra">
            <div class="gmail_quote">
              <blockquote class="quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div text="#000000" bgcolor="#FFFFFF"><font
                    color="#888888">
                    <pre class="m_141986904263821312moz-signature" cols="72">-- 
Best regards,
Aleksei Sidorin,
SRR, Samsung Electronics
</pre>
                  </font></div>
                <br>
                ______________________________<wbr>_________________<br>
                cfe-dev mailing list<br>
                <a href="mailto:cfe-dev@lists.llvm.org"
                  moz-do-not-send="true">cfe-dev@lists.llvm.org</a><br>
                <a
                  href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev"
                  rel="noreferrer" target="_blank"
                  moz-do-not-send="true">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
                <br>
              </blockquote>
            </div>
            <br>
          </div>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p>
    <pre class="moz-signature" cols="72">-- 
Best regards,
Aleksei Sidorin,
SRR, Samsung Electronics
</pre>
  </body>
</html>