[llvm-bugs] [Bug 34539] New: decltype(classname.static_member) incorrectly results in a reference

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Sep 9 10:49:49 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=34539

            Bug ID: 34539
           Summary: decltype(classname.static_member) incorrectly results
                    in a reference
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: John.Salmon at deshawresearch.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Created attachment 19127
  --> https://bugs.llvm.org/attachment.cgi?id=19127&action=edit
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$

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170909/0814a82c/attachment.html>


More information about the llvm-bugs mailing list