<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - decltype(classname.static_member) incorrectly results in a reference"
   href="https://bugs.llvm.org/show_bug.cgi?id=34539">34539</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>decltype(classname.static_member) incorrectly results in a reference
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>5.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>John.Salmon@deshawresearch.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19127" name="attach_19127" title="test case">attachment 19127</a> <a href="attachment.cgi?id=19127&action=edit" title="test case">[details]</a></span>
test case

In the attached code, clang incorrectly makes decltype(foo.si) a int
reference.  I believe it should be an int (no reference).  My
reasoning is that foo.si is an un-parenthesized class member access
(per 5.2.5) and that according to 7.6.2p4 decltype(foo.si) should be
the type of the entity named by foo.si, i.e., an int.

FWIW, clang does the right thing for decltype(foo.i).  I see nothing
to indicate that the presence of static in the declaration of foo.si
should change things.


drdws0134$ garden load llvm-clang-libcxx/5.0.0-01c7/bin; clang++  -v
--stdlib=libc++ -std=c++11 decltype.cpp
-Wl,-rpath,$LLVM_CLANG_LIBCXX_PREFIX/lib
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/d/nyc/salmonj-0/gardens/CentOS7/prefixes/llvm-clang-libcxx/5.0.0-01c7/bin
Found candidate GCC installation: /usr/lib/gcc/i686-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/i686-redhat-linux/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

"/d/nyc/salmonj-0/gardens/CentOS7/prefixes/llvm-clang-libcxx/5.0.0-01c7/bin/clang-5.0"
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name decltype.cpp
-mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -resource-dir
/d/nyc/salmonj-0/gardens/CentOS7/prefixes/llvm-clang-libcxx/5.0.0-01c7/lib/clang/5.0.0
-internal-isystem
/d/nyc/salmonj-0/gardens/CentOS7/prefixes/llvm-clang-libcxx/5.0.0-01c7/bin/../include/c++/v1
-internal-isystem /usr/local/include -internal-isystem
/d/nyc/salmonj-0/gardens/CentOS7/prefixes/llvm-clang-libcxx/5.0.0-01c7/lib/clang/5.0.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++11 -fdeprecated-macro -fdebug-compilation-dir
/u/nyc/salmonj/junk/decltypeclangbug -ferror-limit 19 -fmessage-length 158
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o
/tmp/decltype-780405.o -x c++ decltype.cpp
clang -cc1 version 5.0.0 based upon LLVM 5.0.0 default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:

/d/nyc/salmonj-0/gardens/CentOS7/prefixes/llvm-clang-libcxx/5.0.0-01c7/bin/../include/c++/v1
 /usr/local/include

/d/nyc/salmonj-0/gardens/CentOS7/prefixes/llvm-clang-libcxx/5.0.0-01c7/lib/clang/5.0.0/include
 /usr/include
End of search list.
 "/gdn/centos7/0001/x3/prefixes/binutils/2.27-01c7__5ea2b11d7144/bin/ld"
--hash-style=gnu --no-add-needed --eh-frame-hdr -m elf_x86_64 -dynamic-linker
/lib64/ld-linux-x86-64.so.2 -o a.out
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o
-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5
-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../..
-L/d/nyc/salmonj-0/gardens/CentOS7/prefixes/llvm-clang-libcxx/5.0.0-01c7/bin/../lib
-L/lib -L/usr/lib /tmp/decltype-780405.o -rpath
/d/nyc/salmonj-0/gardens/CentOS7/prefixes/llvm-clang-libcxx/5.0.0-01c7/lib
-lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtend.o
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crtn.o
drdws0134$ ./a.out
std::is_same<decltype(foo.si) COMMA int&>::value: 1   ### WRONG - it should be
an int, not int&
&i: 0x7ffd57d41b64
&xx: 0x7ffd57d41b64
&xx == &i: 1    ### WRONG - xx should not reference i.
std::is_same<decltype(foo_t::si) COMMA int>::value: 1
std::is_same<decltype(foo.i) COMMA int>::value: 1
&yy: 0x7ffd57d41b54
&yy == &i: 0
drdws0134$</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>