[llvm-bugs] [Bug 25173] There is a bug in clang when we try to make our own implementation for the "new" operator with side effects.

2021-03-06 Thread via llvm-bugs
https://bugs.llvm.org/show_bug.cgi?id=25173

Danil  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #3 from Danil  ---


*** This bug has been marked as a duplicate of bug 36476 ***

-- 
You are receiving this mail because:
You are on the CC list for the bug.___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 44625] segfault with -ftime-trace when output file cannot be opened

2021-03-06 Thread via llvm-bugs
https://bugs.llvm.org/show_bug.cgi?id=44625

Jonathan Poelen  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #1 from Jonathan Poelen  ---
Fixed with clang-11 (maybe 10):

$ clang++ -ftime-trace -c a.cpp -o folder_that_does_not_exist/a.o
error: unable to open output file 'folder_that_does_not_exist/a.o': 'No such
file or directory'
1 error generated.
error: unable to open output file 'folder_that_does_not_exist/a.json': 'No such
file or directory'

-- 
You are receiving this mail because:
You are on the CC list for the bug.___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 49462] New: type alias that is not fully resolved in the error message

2021-03-06 Thread via llvm-bugs
https://bugs.llvm.org/show_bug.cgi?id=49462

Bug ID: 49462
   Summary: type alias that is not fully resolved in the error
message
   Product: clang
   Version: 11.0
  Hardware: PC
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P
 Component: C++17
  Assignee: unassignedclangb...@nondot.org
  Reporter: jonathan.poe...@gmail.com
CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk

with clang -std=c++17 test.cpp and

using l = std::make_index_sequence<>;
using f = drop_while;
emp_call::f x = 1;


test.cpp:202:19: error: no viable conversion from 'int' to 'emp_call::f'
(aka '_drop_while_result<0UL + sizeof...(xs)>')
emp_call::f x = 1;
  ^   ~

'_drop_while_result<0UL + sizeof...(xs)>' should be '_drop_while_result<6UL>'.


I couldn't make a code smaller than 200 lines because the error occurs from
9992 and above.

-- 
You are receiving this mail because:
You are on the CC list for the bug.___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 49463] New: clang version 11.1.0 - SIGABRT from llvm::raw_fd_ostream::~raw_fd_ostream when stderr redirects to stdin

2021-03-06 Thread via llvm-bugs
https://bugs.llvm.org/show_bug.cgi?id=49463

Bug ID: 49463
   Summary: clang version 11.1.0 - SIGABRT from
llvm::raw_fd_ostream::~raw_fd_ostream when stderr
redirects to stdin
   Product: clang
   Version: 11.0
  Hardware: PC
OS: Linux
Status: NEW
  Severity: normal
  Priority: P
 Component: Frontend
  Assignee: unassignedclangb...@nondot.org
  Reporter: bertr...@jacquin.bzh
CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
richard-l...@metafoo.co.uk

Hi,

The following command can be used to verify if a given option is supported by
$CC:

  $CC -Werror - -E -xc - -o /dev/null

(While -Werror is not required for all compiler, clang will always return 0
even if an option is not supported unless -Werror is also passed as an
argument, hence I will keep mentioning -Werror here).

When the option is recognized or supported a return code of 0 is expected, if
the option is not recognized or supported a return code of 1 is expected with
potential warning on stderr. This is useful in the context of Makefile or build
systems to probe which option can be used, for example, to remove a set of
warnings. Those usually redirect all I/O to /dev/null to prevent from polluting
input or output, and instead only rely on return code:

  $CC -Werror - -E -xc - -o /dev/null < /dev/null 1>&0 2>&0

Here is a example using gcc to assess if -Wmissing-field-initializers
(supported by gcc and clang), -Wclobbered (supported by gcc but not by clang)
and -Wfoobar (supported by neither gcc or clang) are supported (tested with gcc
from 6.5 to 10.2):

  $ gcc -Werror -Wmissing-field-initializers -E -xc - -o /dev/null < /dev/null
1>&0 2>&0
  $ echo $?
  0
  $ gcc -Werror -Wclobbered -E -xc - -o /dev/null < /dev/null 1>&0 2>&0
  $ echo $?
  0
  $ gcc -Werror -Wfoobar -E -xc - -o /dev/null < /dev/null 1>&0 2>&0
  $ echo $?
  1

Here is the same example with clang 11.1.0:

  $ clang -Werror -Wmissing-field-initializers -E -xc - -o /dev/null <
/dev/null 1>&0 2>&0
  $ echo $?
  0
  $ clang -Werror -Wclobbered -E -xc - -o /dev/null < /dev/null 1>&0 2>&0
  Aborted (core dumped)
  $ echo $?
  134
  $ clang -Werror -Wfoobar -E -xc - -o /dev/null < /dev/null 1>&0 2>&0
  Aborted (core dumped)
  $ echo $?
  134

The example show that clang triggers a SIGABRT if an option is not supported,
hence generating a warning and if stderr is redirected to stdin. Digging more
into this, I can see stdout does not matter in this case and only the
redirection of stderr to stdin (both /dev/null) triggers the SIGABRT.

Please note if explicit redirection of stderr to the same output as stdin does
not trigger SIGABRT:

  $ clang -Werror -Wfoobar -E -xc - -o /dev/null < /dev/null 2> /dev/null
  $ echo $?
  1

Same applies with no redirection as all:

  $ clang -Werror -Wfoobar -E -xc - -o /dev/null
  error: unknown warning option '-Wfoobar'; did you mean '-Wformat'?
[-Werror,-Wunknown-warning-option]
  $ echo $?
  1

This specific behaviour can be observed with a more simple use case like:

  $ clang --does-not-exist < /dev/null 2>&0
  Aborted (core dumped)
  $ echo $?
  134

Here is a backtrack from gdb with `clang -Werror -Wclobbered -E -xc - -o
/dev/null < /dev/null 1>&0 2>&0`:

  (gdb) bt
  #0  __GI_raise (sig=sig@entry=6) at
/usr/src/debug/sys-libs/glibc-2.32-r8/glibc-2.32/sysdeps/unix/sysv/linux/raise.c:49
  #1  0x7f7a155205e8 in __GI_abort () at
/usr/src/debug/sys-libs/glibc-2.32-r8/glibc-2.32/stdlib/abort.c:100
  #2  0x7f7a1624960c in llvm::report_fatal_error (Reason=...,
GenCrashDiag=false)
  at
/usr/src/debug/sys-devel/llvm-11.1.0/llvm/lib/Support/ErrorHandling.cpp:126
  #3  0x7f7a1624940a in llvm::report_fatal_error (Reason=...,
GenCrashDiag=false)
  at
/usr/src/debug/sys-devel/llvm-11.1.0/llvm/lib/Support/ErrorHandling.cpp:87
  #4  0x7f7a1639a3fc in llvm::raw_fd_ostream::~raw_fd_ostream
(this=0x7f7a1c659ca0 , __in_chrg=)
  at
/usr/src/debug/sys-devel/llvm-11.1.0/llvm/lib/Support/raw_ostream.cpp:685
  #5  0x7f7a15539a13 in __run_exit_handlers (status=1, listp=0x7f7a156b6598
<__exit_funcs>, run_list_atexit=run_list_atexit@entry=true,
  run_dtors=run_dtors@entry=true) at
/usr/src/debug/sys-libs/glibc-2.32-r8/glibc-2.32/stdlib/exit.c:108
  #6  0x7f7a15539bbc in __GI_exit (status=) at
/usr/src/debug/sys-libs/glibc-2.32-r8/glibc-2.32/stdlib/exit.c:139
  #7  0x7f7a15521e41 in __libc_start_main (main=0x55cb2487e3b3 , argc=8, argv=0x7fff39b270e8, init=,
  fini=, rtld_fini=,
stack_end=0x7fff39b270d8) at
/usr/src/debug/sys-libs/glibc-2.32-r8/glibc-2.32/csu/libc-start.c:348
  #8  0x55cb2487a95a in _start ()

  (gdb) fr 2
  #2  0x7f7a1624960c in llvm::report_fatal_error (Reason=...,
GenCrashDiag=false)
  at
/usr/src/debug/sys-devel/llvm-11.1.0/llvm/lib/Support/ErrorHandling.cpp:126
  126 abort();
  (gdb) info args
  Reason = @

[llvm-bugs] [Bug 49464] New: [InstCombiner] WRONG code

2021-03-06 Thread via llvm-bugs
https://bugs.llvm.org/show_bug.cgi?id=49464

Bug ID: 49464
   Summary: [InstCombiner]  WRONG code
   Product: libraries
   Version: trunk
  Hardware: PC
OS: Linux
Status: NEW
  Severity: normal
  Priority: P
 Component: Scalar Optimizations
  Assignee: unassignedb...@nondot.org
  Reporter: pauls...@linux.vnet.ibm.com
CC: llvm-bugs@lists.llvm.org

Created attachment 24598
  --> https://bugs.llvm.org/attachment.cgi?id=24598&action=edit
reduced testcase

The reduced program has a loop which executes only two iterations.
LoopVectorizer makes a loop with VF=2, but then InstCombiner removes most
relevant parts of both the scalar and vectorized loop.

clang -march=z14 wrong0.i -o a.out -Os -fno-vectorize -w && ./a.out
1
clang -march=z14 wrong0.i -o a.out -Os -w && ./a.out
0

The program is supposed to print '1'.

-- 
You are receiving this mail because:
You are on the CC list for the bug.___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 49465] New: Can std::allocator{}.deallocate non allocate()d pointer during constant evaluation

2021-03-06 Thread via llvm-bugs
https://bugs.llvm.org/show_bug.cgi?id=49465

Bug ID: 49465
   Summary: Can std::allocator{}.deallocate non allocate()d
pointer during constant evaluation
   Product: clang
   Version: trunk
  Hardware: PC
   URL: https://godbolt.org/z/KbWKcx
OS: Linux
Status: NEW
  Keywords: accepts-invalid
  Severity: enhancement
  Priority: P
 Component: C++2a
  Assignee: unassignedclangb...@nondot.org
  Reporter: johel...@gmail.com
CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
johel...@gmail.com, llvm-bugs@lists.llvm.org,
richard-l...@metafoo.co.uk

See https://godbolt.org/z/KbWKcx.
```C++
#include
struct dyn_array {
  int* beg{};
  // ...
  constexpr void reserve(unsigned) {
// ...
std::allocator{}.deallocate(beg, 0);
  }
};
static_assert([] {
  dyn_array a;
  a.reserve(42);
  return a;
}().beg == nullptr);
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 49466] New: clang crashes at -O2

2021-03-06 Thread via llvm-bugs
https://bugs.llvm.org/show_bug.cgi?id=49466

Bug ID: 49466
   Summary: clang crashes at -O2
   Product: libraries
   Version: trunk
  Hardware: PC
OS: Linux
Status: NEW
  Severity: normal
  Priority: P
 Component: Scalar Optimizations
  Assignee: unassignedb...@nondot.org
  Reporter: haoxi...@gmail.com
CC: llvm-bugs@lists.llvm.org

Hi.

This code makes clang-trunk crashed at -O2. Other released versions or optimal
options handle this case well.

$cat small.c
#include 
uint64_t b, g, f, e, d, c;
int m() {
  int i;
  uint64_t p ;
  uint32_t j ;
  uint32_t *k = f;
  uint8_t l;
  for (;;) {
uint8_t a;
for (; i <= 2; i = j) {
  if (j) {
int32_t n;
for (; p; p++)
  if (e)
for (; n; n++)
  ;
  } else {
int8_t o = l >= (0 >= 0);
return o;
  }
  if (d / 0 >= (j = c))
l -= (b /= *k) <= (g %= a);
  for (; e; e++)
;
}
for (l = 7; l; l = d)
  ;
  }
  return 0;
}

$clang -w -O2 small.c
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments:
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations
-disable-free -main-file-name small.c -mrelocation-model static
-mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases
-munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb
-fcoverage-compilation-dir=/home/haoxin/haoxin-data/dut-research/random-compiler-testing/random-test/ccg-test/useful-cases/creduce
-resource-dir
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/lib/clang/13.0.0
-c-isystem /usr/local/include/csmith-2.3.0 -cxx-isystem
/usr/local/include/csmith-2.3.0 -internal-isystem /usr/local/include
-internal-isystem
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/lib/clang/13.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O2
-w
-fdebug-compilation-dir=/home/haoxin/haoxin-data/dut-research/random-compiler-testing/random-test/ccg-test/useful-cases/creduce
-ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops
-vectorize-slp -faddrsig -o /tmp/small-7db9c9.o -x c small.c
1.   parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module 'small.c'.
4.  Running pass 'CodeGen Prepare' on function '@m'
 #0 0x5609c2f5075c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x340875c)
 #1 0x5609c2f4e394 llvm::sys::RunSignalHandlers()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x3406394)
 #2 0x5609c2f4e503 SignalHandler(int) Signals.cpp:0:0
 #3 0x7faad7971980 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #4 0x5609c1fefd2a llvm::LoopBase::getLoopLatch() const
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x24a7d2a)
 #5 0x5609c21b2694 (anonymous
namespace)::CodeGenPrepare::replaceMathCmpWithIntrinsic(llvm::BinaryOperator*,
llvm::Value*, llvm::Value*, llvm::CmpInst*, unsigned int)
CodeGenPrepare.cpp:0:0
 #6 0x5609c21c250e (anonymous
namespace)::CodeGenPrepare::optimizeCmp(llvm::CmpInst*, bool&)
CodeGenPrepare.cpp:0:0
 #7 0x5609c21d22e8 (anonymous
namespace)::CodeGenPrepare::optimizeInst(llvm::Instruction*, bool&)
CodeGenPrepare.cpp:0:0
 #8 0x5609c21d745d (anonymous
namespace)::CodeGenPrepare::runOnFunction(llvm::Function&) (.part.1793)
CodeGenPrepare.cpp:0:0
 #9 0x5609c2717224 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x2bcf224)
#10 0x5609c2717d69 llvm::FPPassManager::runOnModule(llvm::Module&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x2bcfd69)
#11 0x5609c2716b41 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210304/bin/clang-13+0x2bceb41)
#12 0x5609c320df3b (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr >) BackendUtil.cpp:0:0
#13 0x5609c3211135 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::