public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/95250] New: [D] ICE instead of error when trying to use bad template type inside template
@ 2020-05-20 23:17 witold.baryluk+gcc at gmail dot com
2020-06-23 9:55 ` [Bug d/95250] " ibuclaw at gdcproject dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: witold.baryluk+gcc at gmail dot com @ 2020-05-20 23:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95250
Bug ID: 95250
Summary: [D] ICE instead of error when trying to use bad
template type inside template
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: d
Assignee: ibuclaw at gdcproject dot org
Reporter: witold.baryluk+gcc at gmail dot com
Target Milestone: ---
https://godbolt.org/z/xWrXP5
Minimized version
```
module m;
import std.traits : Unsigned;
void* f(T)(T a, T b) {
alias UnsignedVoid = Unsigned!(T);
return cast(T)(cast(T)(cast(UnsignedVoid)(a-b) / 2));
}
//static assert(is(typeof(f(null, null)) == void*)); // ICE
static assert(is(typeof(f!(void*)(null, null)) == void*)); // ICE
```
The code is not correct, but on DMD v2.092.0 and LDC 1.20.1 (LLVM 9.0.1) it
does say static assert is false (which is also incorrect), and doesn't crash.
Instead it should say, something like this:
/usr/lib/gcc/x86_64-linux-gnu/11.0.0/include/d/std/traits.d:7163:13: error:
static assert "Type void* does not have an Unsigned counterpart"
7163 | static assert(false, "Type " ~ T.stringof ~
| ^
Here is a local run, on Linux, amd64.
$ gdc gdc_ice.d
d21: internal compiler error: Segmentation fault
0xbd63ef crash_signal
../../src/gcc/toplev.c:328
0x7f31b746c7ff ???
./signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x71ed1e isAggregate(Type*)
../../src/gcc/d/dmd/opover.c:161
0x71ed1e visit
../../src/gcc/d/dmd/opover.c:586
0x71e935 op_overload(Expression*, Scope*)
../../src/gcc/d/dmd/opover.c:1385
0x6d0b88 Expression::op_overload(Scope*)
../../src/gcc/d/dmd/expression.h:213
0x6d0b88 ExpressionSemanticVisitor::visit(DivExp*)
../../src/gcc/d/dmd/expressionsem.c:6891
0x6cd7b4 semantic(Expression*, Scope*)
../../src/gcc/d/dmd/expressionsem.c:8214
0x6cd7b4 unaSemantic(UnaExp*, Scope*)
../../src/gcc/d/dmd/expressionsem.c:8164
0x6cd7b4 ExpressionSemanticVisitor::visit(CastExp*)
../../src/gcc/d/dmd/expressionsem.c:4203
0x6cd7b4 semantic(Expression*, Scope*)
../../src/gcc/d/dmd/expressionsem.c:8214
0x6cd7b4 unaSemantic(UnaExp*, Scope*)
../../src/gcc/d/dmd/expressionsem.c:8164
0x6cd7b4 ExpressionSemanticVisitor::visit(CastExp*)
../../src/gcc/d/dmd/expressionsem.c:4203
0x6c5a45 semantic(Expression*, Scope*)
../../src/gcc/d/dmd/expressionsem.c:8214
0x74795f StatementSemanticVisitor::visit(ReturnStatement*)
../../src/gcc/d/dmd/statementsem.c:2757
0x74a949 semantic(Statement*, Scope*)
../../src/gcc/d/dmd/statementsem.c:3782
0x74a949 StatementSemanticVisitor::visit(CompoundStatement*)
../../src/gcc/d/dmd/statementsem.c:142
0x743755 semantic(Statement*, Scope*)
../../src/gcc/d/dmd/statementsem.c:3782
0x6e8ba9 FuncDeclaration::semantic3(Scope*)
../../src/gcc/d/dmd/func.c:1711
0x6e8ba9 FuncDeclaration::semantic3(Scope*)
../../src/gcc/d/dmd/func.c:1354
$
$ gdc -v
Using built-in specs.
COLLECT_GCC=gdc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 10.1.0-1'
--with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-10
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none,amdgcn-amdhsa,hsa --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.1.0 (Debian 10.1.0-1)
$
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug d/95250] [D] ICE instead of error when trying to use bad template type inside template
2020-05-20 23:17 [Bug d/95250] New: [D] ICE instead of error when trying to use bad template type inside template witold.baryluk+gcc at gmail dot com
@ 2020-06-23 9:55 ` ibuclaw at gdcproject dot org
2020-06-25 15:37 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-06-23 9:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95250
--- Comment #1 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
(In reply to Witold Baryluk from comment #0)
> https://godbolt.org/z/xWrXP5
>
> Minimized version
>
> ```
> module m;
>
> import std.traits : Unsigned;
>
> void* f(T)(T a, T b) {
> alias UnsignedVoid = Unsigned!(T);
> return cast(T)(cast(T)(cast(UnsignedVoid)(a-b) / 2));
> }
> //static assert(is(typeof(f(null, null)) == void*)); // ICE
> static assert(is(typeof(f!(void*)(null, null)) == void*)); // ICE
> ```
>
> The code is not correct, but on DMD v2.092.0 and LDC 1.20.1 (LLVM 9.0.1) it
> does say static assert is false (which is also incorrect), and doesn't crash.
>
> Instead it should say, something like this:
>
> /usr/lib/gcc/x86_64-linux-gnu/11.0.0/include/d/std/traits.d:7163:13: error:
> static assert "Type void* does not have an Unsigned counterpart"
>
Because the error occurs in a speculative context (is-expression), the error
from Unsigned!() is gagged. The user should only see the static assert is
false message.
To see speculative errors, compile with -Wspeculative.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug d/95250] [D] ICE instead of error when trying to use bad template type inside template
2020-05-20 23:17 [Bug d/95250] New: [D] ICE instead of error when trying to use bad template type inside template witold.baryluk+gcc at gmail dot com
2020-06-23 9:55 ` [Bug d/95250] " ibuclaw at gdcproject dot org
@ 2020-06-25 15:37 ` cvs-commit at gcc dot gnu.org
2020-06-26 13:46 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-25 15:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95250
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:
https://gcc.gnu.org/g:1d19c9cd3dd99ba8885c0fc93223918399f73939
commit r11-1661-g1d19c9cd3dd99ba8885c0fc93223918399f73939
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Tue Jun 23 22:43:27 2020 +0200
d: Merge upstream dmd 90450f3ef.
Fixes a regression caused by an incomplete backport of converting the
Expression semantic pass to a Visitor.
Reviewed-on: https://github.com/dlang/dmd/pull/11314
gcc/d/ChangeLog:
PR d/95250
* dmd/MERGE: Merge upstream dmd 90450f3ef.
gcc/testsuite/ChangeLog:
PR d/95250
* gdc.dg/pr95250.d: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug d/95250] [D] ICE instead of error when trying to use bad template type inside template
2020-05-20 23:17 [Bug d/95250] New: [D] ICE instead of error when trying to use bad template type inside template witold.baryluk+gcc at gmail dot com
2020-06-23 9:55 ` [Bug d/95250] " ibuclaw at gdcproject dot org
2020-06-25 15:37 ` cvs-commit at gcc dot gnu.org
@ 2020-06-26 13:46 ` cvs-commit at gcc dot gnu.org
2020-06-26 13:50 ` cvs-commit at gcc dot gnu.org
2020-06-26 14:09 ` ibuclaw at gdcproject dot org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-26 13:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95250
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:
https://gcc.gnu.org/g:95f5dc7f70b09def9f2002f5cbef986b21d456e3
commit r10-8373-g95f5dc7f70b09def9f2002f5cbef986b21d456e3
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Tue Jun 23 22:43:27 2020 +0200
d: Fix ICE during error recovery in semantic pass
Fixes a regression caused by an incomplete backport of converting the
Expression semantic pass to a Visitor.
gcc/d/ChangeLog:
PR d/95250
* dmd/expressionsem.c (class ExpressionSemanticVisitor): Return
early
if error occurred during semantic of DivExp.
gcc/testsuite/ChangeLog:
PR d/95250
* gdc.dg/pr95250.d: New test.
(cherry picked from commit 1d19c9cd3dd99ba8885c0fc93223918399f73939)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug d/95250] [D] ICE instead of error when trying to use bad template type inside template
2020-05-20 23:17 [Bug d/95250] New: [D] ICE instead of error when trying to use bad template type inside template witold.baryluk+gcc at gmail dot com
` (2 preceding siblings ...)
2020-06-26 13:46 ` cvs-commit at gcc dot gnu.org
@ 2020-06-26 13:50 ` cvs-commit at gcc dot gnu.org
2020-06-26 14:09 ` ibuclaw at gdcproject dot org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-26 13:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95250
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:
https://gcc.gnu.org/g:57096f5c52be8c5f0c29663234f31845bb172216
commit r9-8701-g57096f5c52be8c5f0c29663234f31845bb172216
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Tue Jun 23 22:43:27 2020 +0200
d: Fix ICE during error recovery in semantic pass
Fixes a regression caused by an incomplete backport of converting the
Expression semantic pass to a Visitor.
gcc/d/ChangeLog:
PR d/95250
* dmd/expressionsem.c (class ExpressionSemanticVisitor): Return
early
if error occurred during semantic of DivExp.
gcc/testsuite/ChangeLog:
PR d/95250
* gdc.dg/pr95250.d: New test.
(cherry picked from commit 1d19c9cd3dd99ba8885c0fc93223918399f73939)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug d/95250] [D] ICE instead of error when trying to use bad template type inside template
2020-05-20 23:17 [Bug d/95250] New: [D] ICE instead of error when trying to use bad template type inside template witold.baryluk+gcc at gmail dot com
` (3 preceding siblings ...)
2020-06-26 13:50 ` cvs-commit at gcc dot gnu.org
@ 2020-06-26 14:09 ` ibuclaw at gdcproject dot org
4 siblings, 0 replies; 6+ messages in thread
From: ibuclaw at gdcproject dot org @ 2020-06-26 14:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95250
Iain Buclaw <ibuclaw at gdcproject dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Done
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-06-26 14:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20 23:17 [Bug d/95250] New: [D] ICE instead of error when trying to use bad template type inside template witold.baryluk+gcc at gmail dot com
2020-06-23 9:55 ` [Bug d/95250] " ibuclaw at gdcproject dot org
2020-06-25 15:37 ` cvs-commit at gcc dot gnu.org
2020-06-26 13:46 ` cvs-commit at gcc dot gnu.org
2020-06-26 13:50 ` cvs-commit at gcc dot gnu.org
2020-06-26 14:09 ` ibuclaw at gdcproject dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).