<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Might clang++ be suppressing the errors
      because they come from system headers?<br>
      <br>
      On 31/03/15 01:33, Sean Silva wrote:<br>
    </div>
    <blockquote
cite="mid:CAHnXoakRk6ShwZLvuU9drNwD5gB-rEYOOFjyAH0T5ifD7mTWLA@mail.gmail.com"
      type="cite">
      <div dir="ltr">Looks like a bug in this:
        <div><br>
        </div>
        <div>
          <div>  template<typename _Value></div>
          <div>    struct __numeric_traits</div>
          <div>    : public
            __conditional_type<std::__is_integer<_Value>::__value,</div>
          <div>    __numeric_traits_integer<_Value>,</div>
          <div>    __numeric_traits_floating<_Value> >::__type</div>
          <div>    { };</div>
        </div>
        <div><br>
        </div>
        <div>Which causes __numeric_traits_integer<_Value> to be
          evaluated with a floating point type (which is the error
          you're seeing). std::conditional doesn't "short circuit" (see
          e.g. <a moz-do-not-send="true"
href="http://stackoverflow.com/questions/24098278/stdconditional-compile-time-branch-evaluation">http://stackoverflow.com/questions/24098278/stdconditional-compile-time-branch-evaluation</a>
          )</div>
        <div><br>
        </div>
        <div>That would suggest that this code would always trigger this
          issue... but I'm curious how this works with clang++
          standalone, but not with the tool.</div>
        <div><br>
        </div>
        <div>-- Sean Silva</div>
        <div>
          <div class="gmail_extra"><br>
            <div class="gmail_quote">On Sat, Mar 28, 2015 at 9:57 PM,
              Peter Stirling <span dir="ltr"><<a
                  moz-do-not-send="true"
                  href="mailto:peter@pjstirling.plus.com"
                  target="_blank">peter@pjstirling.plus.com</a>></span>
              wrote:<br>
              <blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                <div bgcolor="#FFFFFF" text="#000000">
                  <div>This is at the outer limits of my understanding
                    of templates, but if I comment out the following <br>
                    <br>
                      inline
                    string                                                                                                                                                                                                                           

                    <br>
                      to_string(float
                    __val)                                                                                                                                                                                                                    

                    <br>
                     
                    {                                                                                                                                                                                                                                         

                    <br>
                        const int __n
                    =                                                                                                                                                                                                                         

                    <br>
                         
                    __gnu_cxx::__numeric_traits<float>::__max_exponent10
                    +
                    20;                                                                                                                                                                            

                    <br>
                        return
                    __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
                    __n,                                                                                                                                                                            

                    <br>
                            "%f",
                    __val);                                                                                                                                                                                                                       

                    <br>
                     
                    }                                                                                                                                                                                                                                         

                    <br>
                                                                                                                                                                                                                                                                

                    <br>
                      inline
                    string                                                                                                                                                                                                                             

                    <br>
                      to_string(double
                    __val)                                                                                                                                                                                                                   

                    <br>
                     
                    {                                                                                                                                                                                                                                         

                    <br>
                        const int __n
                    =                                                                                                                                                                                                                         

                    <br>
                         
                    __gnu_cxx::__numeric_traits<double>::__max_exponent10
                    +
                    20;                                                                                                                                                                           

                    <br>
                        return
                    __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
                    __n,                                                                                                                                                                            

                    <br>
                            "%f",
                    __val);                                                                                                                                                                                                                       

                    <br>
                     
                    }                                                                                                                                                                                                                                         

                    <br>
                                                                                                                                                                                                                                                                

                    <br>
                      inline
                    string                                                                                                                                                                                                                             

                    <br>
                      to_string(long double
                    __val)                                                                                                                                                                                                              

                    <br>
                     
                    {                                                                                                                                                                                                                                         

                    <br>
                        const int __n
                    =                                                                                                                                                                                                                         

                    <br>
                          __gnu_cxx::__numeric_traits<long
                    double>::__max_exponent10 +
                    20;                                                                                                                                                                      

                    <br>
                        return
                    __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
                    __n,                                                                                                                                                                            

                    <br>
                            "%Lf",
                    __val);                                                                                                                                                                                                                      

                    <br>
                      }                                        <br>
                    <br>
                    Then the errors go away.
                    <div>
                      <div class="h5"><br>
                        <br>
                        On 26/03/15 21:48, Sean Silva wrote:<br>
                      </div>
                    </div>
                  </div>
                  <div>
                    <div class="h5">
                      <blockquote type="cite">
                        <div dir="ltr">
                          <div>Yeah, looks like the resource dir issue
                            isn't it (btw you can pass the -resource-dir
                            option instead of -I in order to precisely
                            match the behavior, but -I is usually
                            enough).<br>
                            <br>
                          </div>
                          <div>The problem appears to be due to
                            __gnu_cxx::__numeric_traits_integer being
                            instantiated with a floating point type...
                            can you look at that code path to see how it
                            is getting there? Maybe it is relying on a
                            particular compiler intrinsic that clang is
                            not treating the same as GCC (or doesn't
                            support?)?<br>
                          </div>
                          <div><br>
                          </div>
                          -- Sean Silva<br>
                          <div>
                            <div>
                              <div class="gmail_extra"><br>
                                <div class="gmail_quote">On Thu, Mar 26,
                                  2015 at 11:45 AM, Peter Stirling <span
                                    dir="ltr"><<a
                                      moz-do-not-send="true"
                                      href="mailto:peter@pjstirling.plus.com"
                                      target="_blank">peter@pjstirling.plus.com</a>></span>
                                  wrote:<br>
                                  <blockquote class="gmail_quote"
                                    style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
                                    <div bgcolor="#FFFFFF"
                                      text="#000000">
                                      <div>Some tests that I've done:<br>
                                        <br>
                                        First to investigate what is
                                        said by -v:<br>
                                        <br>
                                        [peter@fred llvm]$ which clang++<br>
~/Programming/unix-built/clang/bin/clang++<br>
                                        [peter@fred llvm]$ clang++ -v<br>
                                        clang version 3.7.0 (trunk
                                        233281)<br>
                                        Target: x86_64-unknown-linux-gnu<br>
                                        Thread model: posix<br>
                                        Found candidate GCC
                                        installation:
                                        /usr/lib/gcc/x86_64-redhat-linux/4.9.2<br>
                                        Selected GCC installation:
                                        /usr/lib/gcc/x86_64-redhat-linux/4.9.2<br>
                                        Candidate multilib: .;@m64<br>
                                        Candidate multilib: 32;@m32<br>
                                        Selected multilib: .;@m64<br>
                                        <br>
                                        [peter@fred llvm]$ which quaff<br>
~/Programming/unix-built/clang/bin/quaff<br>
                                        [peter@fred llvm]$ quaff -- -v<br>
                                        clang version 3.7.0 (trunk
                                        233281)<br>
                                        Target: x86_64-unknown-linux-gnu<br>
                                        Thread model: posix<br>
                                        Found candidate GCC
                                        installation:
                                        /../lib/gcc/x86_64-redhat-linux/4.9.2<br>
                                        Found candidate GCC
                                        installation:
                                        /usr/lib/gcc/x86_64-redhat-linux/4.9.2<br>
                                        Selected GCC installation:
                                        /../lib/gcc/x86_64-redhat-linux/4.9.2<br>
                                        Candidate multilib: .;@m64<br>
                                        Candidate multilib: 32;@m32<br>
                                        Selected multilib: .;@m64<br>
                                        <br>
                                        /lib is a symlink to /usr/lib,
                                        so there is really only one
                                        installation, but I'm not sure
                                        why they don't use the same
                                        list, either both should have
                                        one candidate, or both should
                                        have two.<br>
                                        <br>
                                        <br>
                                        I then tried (with only failure
                                        to show for it) a bunch of
                                        combinations of -isystem, and -I
                                        for the directory<br>
                                        <br>
/home/peter/Programming/unix-built/clang/lib/clang/3.7.0/include/<br>
                                        <br>
                                        Which should be the right path
                                        for the builtin includes, since
                                        I use the install prefix <br>
                                        <br>
/home/peter/Programming/unix-built/clang/<br>
                                        <br>
                                         (The contents certainly looks
                                        right)<br>
                                        <br>
                                        Any further suggestions?
                                        <div>
                                          <div><br>
                                            <br>
                                            On 26/03/15 01:53, Sean
                                            Silva wrote:<br>
                                          </div>
                                        </div>
                                      </div>
                                      <div>
                                        <div>
                                          <blockquote type="cite">
                                            <div dir="ltr">Although the
                                              errors don't look like it,
                                              could it be something
                                              like: <a
                                                moz-do-not-send="true"
href="http://clang.llvm.org/docs/FAQ.html#i-get-errors-about-some-headers-being-missing-stddef-h-stdarg-h"
                                                target="_blank">http://clang.llvm.org/docs/FAQ.html#i-get-errors-about-some-headers-being-missing-stddef-h-stdarg-h</a> ?


                                              <div><br>
                                              </div>
                                              <div><br>
                                              </div>
                                              <div>-- Sean Silva</div>
                                            </div>
                                            <div class="gmail_extra"><br>
                                              <div class="gmail_quote">On
                                                Wed, Mar 25, 2015 at
                                                6:37 PM, Peter Stirling
                                                <span dir="ltr"><<a
                                                    moz-do-not-send="true"
href="mailto:peter@pjstirling.plus.com" target="_blank">peter@pjstirling.plus.com</a>></span>
                                                wrote:<br>
                                                <blockquote
                                                  class="gmail_quote"
                                                  style="margin:0px 0px
                                                  0px
0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
                                                  <div bgcolor="#FFFFFF"
                                                    text="#000000">
                                                    <div>It doesn't,
                                                      unfortunately (I
                                                      had subsequently
                                                      figured out where
                                                      it was creeping in
                                                      from).
                                                      <div>
                                                        <div><br>
                                                          <br>
                                                          On 26/03/15
                                                          01:27, Sean
                                                          Silva wrote:<br>
                                                        </div>
                                                      </div>
                                                    </div>
                                                    <div>
                                                      <div>
                                                        <blockquote
                                                          type="cite">
                                                          <div dir="ltr">Does
                                                          the error go
                                                          away with
                                                          '-fcolor-diagnostics'
                                                          instead of <span
style="font-size:13px">'-fcolor-diagnosticsoo'?</span> If it does, then
                                                          maybe <span
                                                          style="font-size:13px">'-fcolor-diagnosticsoo'



                                                          is generating
                                                          an error that
                                                          is not being
                                                          handled
                                                          correctly in
                                                          the tool.</span>
                                                          <div><span
                                                          style="font-size:13px"><br>
                                                          </span></div>
                                                          <div><span
                                                          style="font-size:13px">--

                                                          Sean Silva</span></div>
                                                          </div>
                                                          <div
                                                          class="gmail_extra"><br>
                                                          <div
                                                          class="gmail_quote">On

                                                          Wed, Mar 25,
                                                          2015 at 10:32
                                                          AM, Peter
                                                          Stirling <span
                                                          dir="ltr"><<a
moz-do-not-send="true" href="mailto:peter@pjstirling.plus.com"
                                                          target="_blank">peter@pjstirling.plus.com</a>></span>
                                                          wrote:<br>
                                                          <blockquote
                                                          class="gmail_quote"
                                                          style="margin:0px
                                                          0px 0px
0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Hi,<br>
                                                          <br>
                                                          I'm seeing
                                                          some odd
                                                          behaviour that
                                                          I hope someone
                                                          can suggest a
                                                          solution for:<br>
                                                          <br>
                                                          Recently, when
                                                          I run my tool
                                                          on my test
                                                          file I get
                                                          errors that I
                                                          don't get if I
                                                          run clang++
                                                          with
                                                          equivalent
                                                          options -<br>
                                                          <br>
                                                          <br>
                                                          In file
                                                          included from
/home/peter/Programming/llvm/llvm/tools/clang/tools/extra/quaff/dummy.cc:6:<br>
                                                          In file
                                                          included from
/usr/include/taglib/taglib.h:47:<br>
                                                          In file
                                                          included from
/../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/string:40:<br>
                                                          In file
                                                          included from
/../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/char_traits.h:39:<br>
                                                          In file
                                                          included from
/../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/stl_algobase.h:63:<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:58:35:



                                                          error: invalid
                                                          operands to
                                                          binary
                                                          expression
                                                          ('float' and
                                                          'unsigned
                                                          long')<br>
                                                                static
                                                          const _Value
                                                          __min =
                                                          __glibcxx_min(_Value);<br>
                                                                       
                                                                       
                                                               
                                                          ^~~~~~~~~~~~~~~~~~~~~<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:48:35:



                                                          note: expanded
                                                          from macro
                                                          '__glibcxx_min'<br>
                                                           
                                                          (__glibcxx_signed(_Tp)
                                                          ? (_Tp)1
                                                          <<
                                                          __glibcxx_digits(_Tp)
                                                          : (_Tp)0)<br>
                                                                       
                                                                     
                                                           ~~~~~~ ^ 
                                                          ~~~~~~~~~~~~~~~~~~~~~<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:55:12:



                                                          note: in
                                                          instantiation
                                                          of template
                                                          class
                                                          '__gnu_cxx::__numeric_traits_integer<float>'
                                                          requested here<br>
                                                              struct
                                                          __numeric_traits_integer<br>
                                                                     ^<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:59:35:



                                                          error: invalid
                                                          operands to
                                                          binary
                                                          expression
                                                          ('float' and
                                                          'unsigned
                                                          long')<br>
                                                                static
                                                          const _Value
                                                          __max =
                                                          __glibcxx_max(_Value);<br>
                                                                       
                                                                       
                                                               
                                                          ^~~~~~~~~~~~~~~~~~~~~<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:52:15:



                                                          note: expanded
                                                          from macro
                                                          '__glibcxx_max'<br>
                                                             (((((_Tp)1
                                                          <<
                                                          (__glibcxx_digits(_Tp)
                                                          - 1)) - 1)
                                                          << 1) +
                                                          1) : ~(_Tp)0)<br>
                                                                 ~~~~~~
                                                          ^ 
                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:58:35:



                                                          error: invalid
                                                          operands to
                                                          binary
                                                          expression
                                                          ('double' and
                                                          'unsigned
                                                          long')<br>
                                                                static
                                                          const _Value
                                                          __min =
                                                          __glibcxx_min(_Value);<br>
                                                                       
                                                                       
                                                               
                                                          ^~~~~~~~~~~~~~~~~~~~~<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:48:35:



                                                          note: expanded
                                                          from macro
                                                          '__glibcxx_min'<br>
                                                           
                                                          (__glibcxx_signed(_Tp)
                                                          ? (_Tp)1
                                                          <<
                                                          __glibcxx_digits(_Tp)
                                                          : (_Tp)0)<br>
                                                                       
                                                                     
                                                           ~~~~~~ ^ 
                                                          ~~~~~~~~~~~~~~~~~~~~~<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:55:12:



                                                          note: in
                                                          instantiation
                                                          of template
                                                          class
                                                          '__gnu_cxx::__numeric_traits_integer<double>'
                                                          requested here<br>
                                                              struct
                                                          __numeric_traits_integer<br>
                                                                     ^<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:59:35:



                                                          error: invalid
                                                          operands to
                                                          binary
                                                          expression
                                                          ('double' and
                                                          'unsigned
                                                          long')<br>
                                                                static
                                                          const _Value
                                                          __max =
                                                          __glibcxx_max(_Value);<br>
                                                                       
                                                                       
                                                               
                                                          ^~~~~~~~~~~~~~~~~~~~~<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:52:15:



                                                          note: expanded
                                                          from macro
                                                          '__glibcxx_max'<br>
                                                             (((((_Tp)1
                                                          <<
                                                          (__glibcxx_digits(_Tp)
                                                          - 1)) - 1)
                                                          << 1) +
                                                          1) : ~(_Tp)0)<br>
                                                                 ~~~~~~
                                                          ^ 
                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:58:35:



                                                          error: invalid
                                                          operands to
                                                          binary
                                                          expression
                                                          ('long double'
                                                          and 'unsigned
                                                          long')<br>
                                                                static
                                                          const _Value
                                                          __min =
                                                          __glibcxx_min(_Value);<br>
                                                                       
                                                                       
                                                               
                                                          ^~~~~~~~~~~~~~~~~~~~~<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:48:35:



                                                          note: expanded
                                                          from macro
                                                          '__glibcxx_min'<br>
                                                           
                                                          (__glibcxx_signed(_Tp)
                                                          ? (_Tp)1
                                                          <<
                                                          __glibcxx_digits(_Tp)
                                                          : (_Tp)0)<br>
                                                                       
                                                                     
                                                           ~~~~~~ ^ 
                                                          ~~~~~~~~~~~~~~~~~~~~~<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:55:12:



                                                          note: in
                                                          instantiation
                                                          of template
                                                          class
                                                          '__gnu_cxx::__numeric_traits_integer<long
                                                          double>'
                                                          requested here<br>
                                                              struct
                                                          __numeric_traits_integer<br>
                                                                     ^<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:59:35:



                                                          error: invalid
                                                          operands to
                                                          binary
                                                          expression
                                                          ('long double'
                                                          and 'unsigned
                                                          long')<br>
                                                                static
                                                          const _Value
                                                          __max =
                                                          __glibcxx_max(_Value);<br>
                                                                       
                                                                       
                                                               
                                                          ^~~~~~~~~~~~~~~~~~~~~<br>
                                                          /../lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/ext/numeric_traits.h:52:15:



                                                          note: expanded
                                                          from macro
                                                          '__glibcxx_max'<br>
                                                             (((((_Tp)1
                                                          <<
                                                          (__glibcxx_digits(_Tp)
                                                          - 1)) - 1)
                                                          << 1) +
                                                          1) : ~(_Tp)0)<br>
                                                                 ~~~~~~
                                                          ^ 
                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
                                                          <br>
                                                          I extracted
                                                          the command
                                                          line produced
                                                          by the
                                                          FixedCompilationDatabase
                                                          and printed it
                                                          with quotes
                                                          for extra
                                                          paranoia:<br>
                                                          <br>
                                                          'clang-tool'
                                                          '-Wall'
                                                          '-std=c++11'
                                                          '-fcolor-diagnosticsoo'
'/home/peter/Programming/llvm/llvm/tools/clang/tools/extra/quaff/dummy.cc'<br>
                                                          <br>
                                                          First thing to
                                                          observe is
                                                          that
                                                          -fcolor-diagnosticsoo
                                                          seems a bit
                                                          weird. Second
                                                          is that
                                                          running
                                                          clang++ -Wall
                                                          -std=c++11
                                                          /home/peter/Programming/llvm/llvm/tools/clang/tools/extra/quaff/dummy.cc
                                                          doesn't error.<br>
                                                          <br>
                                                          This is on a
                                                          fedora box, if
                                                          that makes a
                                                          difference.<br>
_______________________________________________<br>
                                                          cfe-dev
                                                          mailing list<br>
                                                          <a
                                                          moz-do-not-send="true"
href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
                                                          <a
                                                          moz-do-not-send="true"
href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
                                                          </blockquote>
                                                          </div>
                                                          <br>
                                                          </div>
                                                        </blockquote>
                                                        <br>
                                                      </div>
                                                    </div>
                                                  </div>
                                                </blockquote>
                                              </div>
                                              <br>
                                            </div>
                                          </blockquote>
                                          <br>
                                        </div>
                                      </div>
                                    </div>
                                  </blockquote>
                                </div>
                                <br>
                              </div>
                            </div>
                          </div>
                        </div>
                      </blockquote>
                      <br>
                    </div>
                  </div>
                </div>
                <br>
                _______________________________________________<br>
                cfe-dev mailing list<br>
                <a moz-do-not-send="true"
                  href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
                <a moz-do-not-send="true"
                  href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev"
                  target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
                <br>
              </blockquote>
            </div>
            <br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>