[Bug d/101490] New: ICE at convert_expr(tree_node*, Type*, Type*)

2021-07-17 Thread SztfG at yandex dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101490

Bug ID: 101490
   Summary: ICE at convert_expr(tree_node*, Type*, Type*)
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: d
  Assignee: ibuclaw at gdcproject dot org
  Reporter: SztfG at yandex dot ru
  Target Milestone: ---

testcase:

import std.stdio;

struct test
{
  int[0] foo;
};

void main()
{
  test* t;
  auto a = cast(typeof((*t).foo)[0])t.foo;
  writeln(a);
}


/opt/wandbox/gdc-head/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include/d/std/format.d:
In function 'formatValue':
/opt/wandbox/gdc-head/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include/d/std/format.d:2605:23:
internal compiler error: Floating point exception
 2605 | formatValue(w, obj[], f);
  |   ^
0xc2df5f crash_signal
../../source/gcc/toplev.c:328
0x7b78c4 convert_expr(tree_node*, Type*, Type*)
../../source/gcc/d/d-convert.cc:476
0x7c9a5e ExprVisitor::visit(SliceExp*)
../../source/gcc/d/expr.cc:1382
0x7c74c0 build_expr(Expression*, bool, bool)
../../source/gcc/d/expr.cc:3129
0x7b60d1 d_build_call(TypeFunction*, tree_node*, tree_node*,
Array*)
../../source/gcc/d/d-codegen.cc:2042
0x7c8f34 ExprVisitor::visit(CallExp*)
../../source/gcc/d/expr.cc:1886
0x7c74c0 build_expr(Expression*, bool, bool)
../../source/gcc/d/expr.cc:3129
0x7c755b build_expr_dtor(Expression*)
../../source/gcc/d/expr.cc:3152
0x7d3cf1 IRVisitor::visit(ExpStatement*)
../../source/gcc/d/toir.cc:1120
0x7d37bf IRVisitor::build_stmt(Statement*)
../../source/gcc/d/toir.cc:274
0x7d37bf IRVisitor::visit(CompoundStatement*)
../../source/gcc/d/toir.cc:1137
0x7d37bf IRVisitor::visit(CompoundStatement*)
../../source/gcc/d/toir.cc:1127
0x7d2e12 IRVisitor::build_stmt(Statement*)
../../source/gcc/d/toir.cc:274
0x7d2e12 build_function_body(FuncDeclaration*)
../../source/gcc/d/toir.cc:1549
0x7c6623 DeclVisitor::visit(FuncDeclaration*)
../../source/gcc/d/decl.cc:945
0x7c5b2f DeclVisitor::build_dsymbol(Dsymbol*)
../../source/gcc/d/decl.cc:146
0x7c5b2f DeclVisitor::visit(TemplateInstance*)
../../source/gcc/d/decl.cc:341
0x7c5b2f DeclVisitor::visit(TemplateInstance*)
../../source/gcc/d/decl.cc:332
0x7c31d6 DeclVisitor::build_dsymbol(Dsymbol*)
../../source/gcc/d/decl.cc:146
0x7c31d6 build_decl_tree(Dsymbol*)
../../source/gcc/d/decl.cc:986
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug d/101441] New: __FUNCTION__ doesn't work in core.stdc.stdio functions without cast

2021-07-13 Thread SztfG at yandex dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101441

Bug ID: 101441
   Summary: __FUNCTION__ doesn't work in core.stdc.stdio functions
without cast
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: d
  Assignee: ibuclaw at gdcproject dot org
  Reporter: SztfG at yandex dot ru
  Target Milestone: ---

testcase:

import core.stdc.stdio;

extern(C) int main(int argc, char **argv)
{
  // works in ldc, dmd, doesnt work in gdc
  puts(__FUNCTION__);
  puts("test" ~ __FUNCTION__ ~ "test");

  // works everywhere
  puts(cast(char*)__FUNCTION__);
  puts(cast(char*)("test " ~ __FUNCTION__ ~ "test"));
  return 0;
}

[Bug d/101440] New: Documentation bug for __attribute__ ((access))

2021-07-13 Thread SztfG at yandex dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101440

Bug ID: 101440
   Summary: Documentation bug for __attribute__ ((access))
   Product: gcc
   Version: 10.1.0
   URL: https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Common-F
unction-Attributes.html
Status: UNCONFIRMED
  Keywords: documentation
  Severity: normal
  Priority: P3
 Component: d
  Assignee: ibuclaw at gdcproject dot org
  Reporter: SztfG at yandex dot ru
  Target Milestone: ---

>From documentation:

> Examples of the use of the read_only access mode is the argument to the puts 
> function, or the second and third arguments to the memcpy function.

> __attribute__ ((access (read_only, 1, 2))) void* memcpy (void*, const void*, 
> size_t);

There is no reference to "third argument in memcpy function". Or I don't
understand something? Maybe there must be 

__attribute__ ((access (write_only, 1, 3), access (read_only, 2, 3))) void*
memcpy (void* restrict, const void* restrict, size_t);

so, if we have
void *memcpy(void *dest, const void *src, size_t n);

then this function can write "size_t n" bytes to "void *dest" and read "size_t
n" bytes from "void *src"