[Bug c++/78160] New: explicit template instantation with hidden symbols fails

2016-10-29 Thread gcc at ebasoft dot com.pl
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78160

Bug ID: 78160
   Summary: explicit template instantation with hidden symbols
fails
   Product: gcc
   Version: 6.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc at ebasoft dot com.pl
  Target Milestone: ---

Created attachment 39922
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39922&action=edit
full source code with CMake configuration

When some template struct is specialized in shared library on other type that
has hidden visibility it passes compilation but no code is generated.
This causes missing symbols in library. If base type is required to be default
visible it should fail at compilation stage with error instead of causing hard
to understand source of problems.

I reproducted this error on gcc 5.4.1, 6.2.0

//Example code (full cmake project attached)
///LIBRARY HEADER some_shared.h
//--
#include 
#include 

#define visibility_hidden __attribute__((visibility("hidden")))
#define visibility_default __attribute__((visibility("default")))

struct visibility_default base_spec_char
  {
  using value_type  = char;
  char foo[10];
  };

//SPECIALIZING ON THIS TYPE WILL CAUSE MISSING CODE AND SYMBOLS
struct visibility_hidden base_spec_uint8
  {
  using value_type  = uint8_t;
  uint8_t foo[20];
  };

template
struct visibility_default var_t
  {
  using var_store_t = VarStoreType;
  using value_type  = typename var_store_t::value_type;

  std::unique_ptr alloc();
  };
using varchar_t = var_t;
using varbinary_t = var_t;

///LIBRARY SOURCE
//--
#include "some_shared.h"

template
std::unique_ptr::var_store_t>
 var_t::alloc( )
  {
  return std::make_unique();
  }

template struct var_t;
template struct var_t;

//MAIN PROGRAM LINKED TO SHARED LIBRARY
#include 
#include "some_shared.h"

int main(int argc, char **argv) 
  {
  varchar_t foo;
  varbinary_t bar;

  auto obj = foo.alloc();
  auto obj2 = bar.alloc(); //<- unresolved symbols
  std::cout << "Hello, world!"<< obj.get()<< obj2.get() << std::endl;
  return 0;
  }
main.cpp:10: undefined reference to `var_t::alloc()'

[Bug c++/102286] [constexpr] construct_at incorrectly starts union array lifetime in some cases

2022-02-18 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102286

Artur Bać  changed:

   What|Removed |Added

 CC||gcc at ebasoft dot com.pl

--- Comment #4 from Artur Bać  ---
This is not legal in c++20 but gcc allows accessing not active member of a
union in constexpr

https://godbolt.org/z/KsEhffeEa

clang refuses and it is right

"construction of subobject of member 'object' of union with active member
'init' is not allowed in a constant expression"
With c++20 there is no way to have aligned_storage for not trivial type in
constexpr (storage without initialization, not std::array that requires
construction of non trivial objects upon member activation)

https://godbolt.org/z/9EGrf8fbr

#include 

struct foo
{
int * i;
constexpr foo() { i = new int; }
constexpr ~foo() { delete(i); }
};
union storage
{
  constexpr storage() 
  : init{}
  {}
  constexpr ~storage() {}

  foo object[1];
  char init = '\0';
  };

consteval bool test()
{
storage u;
auto p = std::addressof(u.object[0]);
std::construct_at(p);
std::destroy_at(p);
return true;
}

int main()
{ 
static_assert( test() );
return test();
}

[Bug c++/100983] Deduction guide for member template class rejected at class scope

2022-02-22 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100983

Artur Bać  changed:

   What|Removed |Added

 CC||gcc at ebasoft dot com.pl

--- Comment #4 from Artur Bać  ---
trunk at compiler explorer still rejects valid code

https://godbolt.org/z/v4ebhj9Gh, only the message of requirement of namespace
scope is missing from gcc 11.2, invalid use of template-name without an
argument list

https://godbolt.org/z/7Wev6saWz "ctad" must be declared at namespace scope +
invalid use of template-name without an argument list

clang https://godbolt.org/z/vavPTbf36 works as expected

[Bug c++/104636] New: implicit use of explicit constructor

2022-02-22 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104636

Bug ID: 104636
   Summary: implicit use of explicit constructor
   Product: gcc
   Version: 11.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc at ebasoft dot com.pl
  Target Milestone: ---

during build of kde-misc/kdeconnect with clang and then gcc I found that gcc
allows implicit use of explicit ctor mentioning even that it would use
explicit, it sounds like it is compiling this as c++98 or so ..

https://godbolt.org/z/WsWPbbKfe

:14:13: warning: converting to 'foo' from initializer list would use
explicit constructor 'foo::foo(const char*, uint8_t)'
   14 | return {};
  | ^
:14:13: note: in C++11 and above a default constructor can be explicit

similar bug was resolved and fixed
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40685

[Bug c++/100983] Deduction guide for member template class rejected at class scope

2022-02-22 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100983

--- Comment #6 from Artur Bać  ---
The typename was from my real code by mistake where value_type s template
param.
But in real code withing template I have to use typename and it doesn't work
with trunk too.

https://godbolt.org/z/E6Pavhfza

[Bug c++/100983] Deduction guide for member template class rejected at class scope

2022-02-22 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100983

--- Comment #7 from Artur Bać  ---
Do I have to open new bug because of You marked it as fixed while it is not
fixed ?

[Bug c++/104641] New: Deduction guide for member template class rejected at class scope when used with typename dependant type

2022-02-22 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104641

Bug ID: 104641
   Summary: Deduction guide for member template class rejected at
class scope when used with typename dependant type
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc at ebasoft dot com.pl
  Target Milestone: ---

Follow up of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100983

Doesn't work when used with template typename inside template
https://godbolt.org/z/E6Pavhfza

[Bug c++/100983] Deduction guide for member template class rejected at class scope

2022-02-22 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100983

--- Comment #9 from Artur Bać  ---
created https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104641

[Bug c++/104636] implicit use of explicit constructor

2022-03-06 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104636

--- Comment #4 from Artur Bać  ---
So conclusion from Your arguments is to me that -std=c++20 doesn't guarantee
strict c++20 compatibility as another switches are required to force explicit
constructor be used only explicitly and disallow implicit construction with
explicit constructor.

[Bug c++/58855] Attributes ignored on type alias in template

2022-01-30 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58855

gcc at ebasoft dot com.pl changed:

   What|Removed |Added

 CC||gcc at ebasoft dot com.pl

--- Comment #3 from gcc at ebasoft dot com.pl ---
This bug is still present in gcc version 11.2.1 20220115

namespace concepts
{
 template
 concept arithmetic = std::integral || std::floating_point;
}
template
using point_vector = T __attribute__((__vector_size__(sizeof(T)*2)));

warning: ignoring attributes applied to dependent type ‘T’ without an
associated declaration [-Wattributes]
   70 | using point_vector = T
__attribute__((__vector_size__(sizeof(T)*2)));
  |   
^

[Bug c++/104386] New: no_unique_address causes invalid member alignment of pod struct

2022-02-04 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104386

Bug ID: 104386
   Summary: no_unique_address causes invalid member alignment of
pod struct
   Product: gcc
   Version: 11.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc at ebasoft dot com.pl
  Target Milestone: ---

struct base
{ [[no_unique_address]]
 uint32_t x; std::byte v;
 };
struct foo : public base
 { std::byte z; };

gcc sizeof(foo) == 8 https://godbolt.org/z/G4Mo3PdKT

clang sizeof(foo) == 12 https://godbolt.org/z/bdzvaMn9c

As I was told it is gcc bug 
https://www.reddit.com/r/cpp/comments/sjx2mk/no_unique_addres_where_can_in_c_standard_instead/

[orbital1337]"Your class base is a POD but its not a POD for the purpose of
layout (since it has potentially overlapping data members). Thus the Itanium
ABI specifies that it's size without padding (dsize) should be set to its size
with padding (sizeof). The first datamember of your class foo is put at
dsize(base). clang does the right thing and puts it at an offset of 8 bytes
whereas gcc ignores that one line of the specification and puts it at an offset
of 5 bytes instead."

[Bug c++/104386] no_unique_address causes invalid member alignment of pod struct

2022-02-06 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104386

--- Comment #2 from Artur Bać  ---
I think it is connected with this case

https://godbolt.org/z/cvfs1KqGW
https://godbolt.org/z/vdzTzo7be

//sizeof(foo) ==12
struct base
{
uint32_t x{};
std::byte v{};

base() noexcept = default;
};

struct foo : public base
{
std::byte z;
};

//sizeof(foo) == 8
struct base
{
uint32_t x;
std::byte v;

base() noexcept : x{}, v{} {}
};

struct foo : public base
{
std::byte z;
};

and

https://www.reddit.com/r/cpp/comments/slfugx/comment/hvs4n7j/?utm_source=share&utm_medium=web2x&context=3

"Som1Lse · 5 hr. ago

Interestingly GCC disagrees with itself:

-std=c++17 it considers base to be a POD and doesn't reuse padding.
-std=c++20 it considers base to not be a POD and agrees with Clang, reusing
the padding bytes."

[Bug libstdc++/102358] niter_base and miter_base overloaded for move_iterator missing constexpr

2022-02-16 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102358

Artur Bać  changed:

   What|Removed |Added

 CC||gcc at ebasoft dot com.pl

--- Comment #2 from Artur Bać  ---
I have spend 20min figuring out why std::copy fails compile at constexpr with
libstdc++ only ;-) and it is already reported.

"* include/bits/stl_iterator.h (__niter_base): Make constexpr for C++20."

c++20 ?
according to cppreference make_move_iterator is constexpr since c++17
https://en.cppreference.com/w/cpp/iterator/make_move_iterator

[Bug libstdc++/102358] niter_base and miter_base overloaded for move_iterator missing constexpr

2022-02-17 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102358

--- Comment #4 from Artur Bać  ---
In 12 ?

In 11.2.1/include/g++-v11/bits/cpp_type_traits.h
 template
_GLIBCXX20_CONSTEXPR
inline _Iterator
__miter_base(_Iterator __it)

and as it was mentioned overload in stl_iterator.h has missing constexpr at
all.

[Bug libstdc++/102358] niter_base and miter_base overloaded for move_iterator missing constexpr

2022-02-17 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102358

--- Comment #6 from Artur Bać  ---
My bad. copy itself is constexpr since c++20, I was misleaded by overload used
for move_iterator with copy that has missing constexpr 

template
auto __miter_base(move_iterator<_Iterator> __it)

[Bug c++/115335] New: std::span at method is missing feature test macro __cpp_lib_span >= 202311L

2024-06-03 Thread gcc at ebasoft dot com.pl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115335

Bug ID: 115335
   Summary: std::span at method is missing feature test macro
__cpp_lib_span >= 202311L
   Product: gcc
   Version: 14.1.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc at ebasoft dot com.pl
  Target Milestone: ---

gcc (Gentoo 14.1.1_p20240518 p1) 14.1.1 20240516
In gcc stdlibc++ 14 there is method span<>::at added that should be visible
only to standard c++26.
https://en.cppreference.com/w/cpp/container/span/at

But implementation is missing feature test macro
__cpp_lib_span >= 202311L and this method is visible for all standards backward
in c++20 and c++23.
availability in backward standards makes difficult to refactor code for example
from vector to span that will be still portable with older gcc like 13 when it
is being done on platform with gcc libstdc++ 14 as there is no compiler error
when method at is being used after refactoring vector to span.