Re: [cfe-users] My compiler crashes .... but the online godbolt one doesn't ?!

2018-12-10 Thread David Blaikie via cfe-users
Possible that the online one isn't built with assertions enabled (you could
test this with other known crashers to see if they reproduce on godbolt
with assertion crash dumps or only with raw segfaults)? If that's the
case,t hen it's possible that the codepath that should assert continues on
and perhaps either has unexpected or even undefined behavior but not a
crash.

On Sat, Dec 8, 2018 at 3:08 PM Andy Gibbs via cfe-users <
cfe-users@lists.llvm.org> wrote:

> Hi,
>
> Crazy question, but would someone kind be able to help me a little here.
> I have
> a clang 4.0 installation on my linux laptop, which crashes when compiling
> this
> code fragment:
>
>   template 
>   constexpr auto fn1() { return X; }
>
>   template 
>   auto fn2()
> {
> return ([]() {
> static constexpr auto value = 12;
> return fn1();
>   })();
> }
>
>   auto test()
> {
> return fn2();
> }
>
> However, doing the same on the godbolt clang 4.0.0 compiler doesn't
> crash.  What
> I can't work out is why!?
>
> The is the command I run on my machine (using a clean checkout from the
> clang
> svn repository) and the output given (the problem seems to be a
> non-instantiated
> VarDecl in "LocalInstantiationScope::findInstantiationOf()" if you add
> debug
> information to the compiler code at this point):
>
>
> $ ~/Toolchains/clang-4.0/bin/clang++ -std=c++1z -O2 -S -o - test.cpp -v
>
> clang version 4.0.0 (branches/release_40)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
> InstalledDir: /home/user/Toolchains/clang-4.0/bin
> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.3.0
> Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.3.0
> Candidate multilib: .;@m64
> Selected multilib: .;@m64
>  "/home/user/Toolchains/clang-4.0/bin/clang-4.0" -cc1 -triple
> x86_64-unknown-linux-gnu -S -disable-free -main-file-name test.cpp
> -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
> -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
> -momit-leaf-frame-pointer -v -dwarf-column-info -debugger-tuning=gdb
> -coverage-notes-file /home/user/test/-.gcno -resource-dir
> /home/user/Toolchains/clang-4.0/bin/../lib/clang/4.0.0 -internal-isystem
> /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0
> -internal-isystem
>
> /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0
> -internal-isystem
>
> /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0
> -internal-isystem
> /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward
> -internal-isystem /usr/local/include -internal-isystem
> /home/user/Toolchains/clang-4.0/bin/../lib/clang/4.0.0/include
> -internal-externc-isystem /usr/include/x86_64-linux-gnu
> -internal-externc-isystem /include -internal-externc-isystem /usr/include
> -O2
> -std=c++1z -fdeprecated-macro -fdebug-compilation-dir /home/user/test
> -ferror-limit 19 -fmessage-length 92 -fobjc-runtime=gcc -fcxx-exceptions
> -fexceptions -fdiagnostics-show-option -fcolor-diagnostics
> -vectorize-loops
> -vectorize-slp -o - -x c++ test.cpp
> clang -cc1 version 4.0.0 based upon LLVM 4.0.0 default target
> x86_64-unknown-linux-gnu
> ignoring nonexistent directory "/include"
> ignoring duplicate directory
>
> "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0"
> #include "..." search starts here:
> #include <...> search starts here:
>  /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0
>
>  
> /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0
>  /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward
>  /usr/local/include
>  /home/user/Toolchains/clang-4.0/bin/../lib/clang/4.0.0/include
>  /usr/include/x86_64-linux-gnu
>  /usr/include
> End of search list.
> clang-4.0:
> /home/user/Toolchains/clang-4.0/source/tools/clang/lib/Sema/
> SemaTemplateInstantiate.cpp:2814: llvm::PointerUnion LocalInstantiationScope::DeclArgumentPack *>
> *clang::LocalInstantiationScope::findInstantiationOf(const clang::Decl *):
> Assertion `isa(D) && "declaration not instantiated in this
> scope"'
> failed.
> 0  clang-4.0   0x01ac29e5
> llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
> 1  clang-4.0   0x01ac30b6
> 2  libpthread.so.0 0x7f1fd115a0c0
> 3  libc.so.6   0x7f1fcfce gsignal + 207
> 4  libc.so.6   0x7f1fcfcf142a abort + 362
> 5  libc.so.6   0x7f1fcfce8e67
> 6  libc.so.6   0x7f1fcfce8f12
> 7  clang-4.0   0x02f0ecb4
> clang::LocalInstantiationScope::findInstantiationOf(clang::Decl const*) +
> 516
> 8  clang-4.0   0x02f2f815
> clang::Sema::FindInstantiatedDecl(clang::SourceLocation,
> clang::NamedDecl*,
> clang::MultiLevelTemplateArgumentList const&) + 181
> [...]
>
>
> The same output from the godbolt compiler give

Re: [cfe-users] My compiler crashes .... but the online godbolt one doesn't ?!

2018-12-10 Thread Jonas Toth via cfe-users
The snippet you show is already quite minimal, so its ok to file another
bug specifically for that one.

Am 10.12.18 um 19:17 schrieb David Blaikie via cfe-users:
> Possible that the online one isn't built with assertions enabled (you
> could test this with other known crashers to see if they reproduce on
> godbolt with assertion crash dumps or only with raw segfaults)? If
> that's the case,t hen it's possible that the codepath that should
> assert continues on and perhaps either has unexpected or even
> undefined behavior but not a crash.
>
> On Sat, Dec 8, 2018 at 3:08 PM Andy Gibbs via cfe-users
> mailto:cfe-users@lists.llvm.org>> wrote:
>
> Hi,
>
> Crazy question, but would someone kind be able to help me a little
> here.  I have
> a clang 4.0 installation on my linux laptop, which crashes when
> compiling this
> code fragment:
>
>   template 
>   constexpr auto fn1() { return X; }
>
>   template 
>   auto fn2()
>     {
>     return ([]() {
>         static constexpr auto value = 12;
>         return fn1();
>       })();
>     }
>
>   auto test()
>     {
>     return fn2();
>     }
>
> However, doing the same on the godbolt clang 4.0.0 compiler
> doesn't crash.  What
> I can't work out is why!?
>
> The is the command I run on my machine (using a clean checkout
> from the clang
> svn repository) and the output given (the problem seems to be a
> non-instantiated
> VarDecl in "LocalInstantiationScope::findInstantiationOf()" if you
> add debug
> information to the compiler code at this point):
>
>
> $ ~/Toolchains/clang-4.0/bin/clang++ -std=c++1z -O2 -S -o -
> test.cpp -v
>
> clang version 4.0.0 (branches/release_40)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
> InstalledDir: /home/user/Toolchains/clang-4.0/bin
> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.3.0
> Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.3.0
> Candidate multilib: .;@m64
> Selected multilib: .;@m64
>  "/home/user/Toolchains/clang-4.0/bin/clang-4.0" -cc1 -triple
> x86_64-unknown-linux-gnu -S -disable-free -main-file-name test.cpp
> -mrelocation-model static -mthread-model posix -fmath-errno
> -masm-verbose
> -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu
> x86-64
> -momit-leaf-frame-pointer -v -dwarf-column-info -debugger-tuning=gdb
> -coverage-notes-file /home/user/test/-.gcno -resource-dir
> /home/user/Toolchains/clang-4.0/bin/../lib/clang/4.0.0
> -internal-isystem
> /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0
> -internal-isystem
> 
> /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0
> -internal-isystem
> 
> /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0
> -internal-isystem
> /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward
>
> -internal-isystem /usr/local/include -internal-isystem
> /home/user/Toolchains/clang-4.0/bin/../lib/clang/4.0.0/include
> -internal-externc-isystem /usr/include/x86_64-linux-gnu
> -internal-externc-isystem /include -internal-externc-isystem
> /usr/include -O2
> -std=c++1z -fdeprecated-macro -fdebug-compilation-dir /home/user/test
> -ferror-limit 19 -fmessage-length 92 -fobjc-runtime=gcc
> -fcxx-exceptions
> -fexceptions -fdiagnostics-show-option -fcolor-diagnostics
> -vectorize-loops
> -vectorize-slp -o - -x c++ test.cpp
> clang -cc1 version 4.0.0 based upon LLVM 4.0.0 default target
> x86_64-unknown-linux-gnu
> ignoring nonexistent directory "/include"
> ignoring duplicate directory
> 
> "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0"
> #include "..." search starts here:
> #include <...> search starts here:
>  /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0
>  
> /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0
>  
> /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward
>  /usr/local/include
>  /home/user/Toolchains/clang-4.0/bin/../lib/clang/4.0.0/include
>  /usr/include/x86_64-linux-gnu
>  /usr/include
> End of search list.
> clang-4.0:
> /home/user/Toolchains/clang-4.0/source/tools/clang/lib/Sema/
> SemaTemplateInstantiate.cpp:2814: llvm::PointerUnion LocalInstantiationScope::DeclArgumentPack *>
> *clang::LocalInstantiationScope::findInstantiationOf(const
> clang::Decl *):
> Assertion `isa(D) && "declaration not instantiated in
> this scope"'
> failed.
> 0  clang-4.0       0x01ac29e5
> llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
> 1  clang-4.0       0x0

[cfe-users] [run-clang-tidy] new replacement overlaps with an existing replacement

2018-12-10 Thread Mateusz Loskot via cfe-users
Hi,

I'm running clang-tidy 7.0 (also tried 5.0) to modernise some aspects
of Boost.GIL (https://github.com/boostorg/gil) source code.

I've noticed, clang-tidy 7.0 (also 5.0) does not apply fixes for some of
modernize-use-* checks, especially modernize-use-using.

I run it this way:

```
cd ${BOOST_ROOT}/libs/gil
cmake -S . -B _build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
run-clang-tidy.py -p=_build -header-filter='boost\/gil\/.*'
-checks='-*,modernize-use-using' -fix
```

Then, I see huge number of "The new replacement overlaps with an
existing replacement." diagnostics.
Below, I copied an extract that hopefully is useful to figure out what
is happening and going wrong.

Basically, there are two class templates and a bunch of tag types:

1. file_stream_device
https://github.com/boostorg/gil/blob/e0288ece9ec50534e7d02166863d6799a5932e25/include/boost/gil/io/device.hpp#L49
2. get_write_device with partial specialisations, `enable_if`-ed
https://github.com/boostorg/gil/blob/e0288ece9ec50534e7d02166863d6799a5932e25/include/boost/gil/io/get_write_device.hpp#L19-L59

The file_stream_device is specialised for a tag and final
get_write_device specialisation is matched.

And, clang-tidy tries to substitute this alias in get_write_device

typedef detail::file_stream_device< FormatTag > type;

not with

using type = detail::file_stream_device< FormatTag > ;

but with `using type` for each FormatTag-based specialisation

```
New replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
Existing replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
The new replacement overlaps with an existing replacement.
New replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
Existing replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
The new replacement overlaps with an existing replacement.
New replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
Existing replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
The new replacement overlaps with an existing replacement.
New replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
Existing replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
The new replacement overlaps with an existing replacement.
New replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
Existing replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
The new replacement overlaps with an existing replacement.
New replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
Existing replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
The new replacement overlaps with an existing replacement.
New replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
Existing replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
The new replacement overlaps with an existing replacement.
New replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
Existing replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
The new replacement overlaps with an existing replacement.
New replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
Existing replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
The new replacement overlaps with an existing replacement.
New replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
Existing replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
The new replacement overlaps with an existing replacement.
New replacement:
/mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
1885:+52:"using type = detail::file_stream_device"
Existing replacement:
/mnt/d/boost.wsl/libs/

Re: [cfe-users] [run-clang-tidy] new replacement overlaps with an existing replacement

2018-12-10 Thread Jonas Toth via cfe-users
Hi Mateusz,

comments inline.

Am 10.12.18 um 22:14 schrieb Mateusz Loskot via cfe-users:
> Hi,
>
> I'm running clang-tidy 7.0 (also tried 5.0) to modernise some aspects
> of Boost.GIL (https://github.com/boostorg/gil) source code.
>
> I've noticed, clang-tidy 7.0 (also 5.0) does not apply fixes for some of
> modernize-use-* checks, especially modernize-use-using.
>
> I run it this way:
>
> ```
> cd ${BOOST_ROOT}/libs/gil
> cmake -S . -B _build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
> run-clang-tidy.py -p=_build -header-filter='boost\/gil\/.*'
> -checks='-*,modernize-use-using' -fix
> ```
>
> Then, I see huge number of "The new replacement overlaps with an
> existing replacement." diagnostics.
> Below, I copied an extract that hopefully is useful to figure out what
> is happening and going wrong.
>
> Basically, there are two class templates and a bunch of tag types:
>
> 1. file_stream_device
> https://github.com/boostorg/gil/blob/e0288ece9ec50534e7d02166863d6799a5932e25/include/boost/gil/io/device.hpp#L49
> 2. get_write_device with partial specialisations, `enable_if`-ed
> https://github.com/boostorg/gil/blob/e0288ece9ec50534e7d02166863d6799a5932e25/include/boost/gil/io/get_write_device.hpp#L19-L59
>
> The file_stream_device is specialised for a tag and final
> get_write_device specialisation is matched.
>
> And, clang-tidy tries to substitute this alias in get_write_device
>
> typedef detail::file_stream_device< FormatTag > type;
>
> not with
>
> using type = detail::file_stream_device< FormatTag > ;
>
> but with `using type` for each FormatTag-based specialisation
>
> ```
> New replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> Existing replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> The new replacement overlaps with an existing replacement.
> New replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> Existing replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> The new replacement overlaps with an existing replacement.
> New replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> Existing replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> The new replacement overlaps with an existing replacement.
> New replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> Existing replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> The new replacement overlaps with an existing replacement.
> New replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> Existing replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> The new replacement overlaps with an existing replacement.
> New replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> Existing replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> The new replacement overlaps with an existing replacement.
> New replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> Existing replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> The new replacement overlaps with an existing replacement.
> New replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> Existing replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> The new replacement overlaps with an existing replacement.
> New replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> Existing replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> The new replacement overlaps with an existing replacement.
> New replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_device.hpp:
> 1885:+52:"using type = detail::file_stream_device"
> Existing replacement:
> /mnt/d/boost.wsl/libs/gil/include/boost/gil/io/get_write_devic