[Bug c++/69906] New: Feature request: better error message when dependent function template parsing fails

2016-02-22 Thread steve.lorimer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69906

Bug ID: 69906
   Summary: Feature request: better error message when dependent
function template parsing fails
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: steve.lorimer at gmail dot com
  Target Milestone: ---

When a dependent type is specified without the `typename` keyword, the error
message generated alludes to this fact:

main.cpp: In function ‘void bar(T&)’:
main.cpp:13:5: error: need ‘typename’ before ‘T:: type’ because ‘T’ is
a dependent scope
 T::type i = 0;
 ^

However, if a dependent function template is specified without the `template`
keyword, the error message doesn't allude to the missing `template` keyword:

main.cpp:10:15: error: expected primary-expression before ‘int’
 type.func();
   ^

The feature request is to extend this helpful `typename` keyword error message
to the case where the missing keyword is `template`.

Example:

struct Foo
{
template
void func() {}
};

template
void bar(T& type)
{
type.func();
}

int main()
{
Foo foo;
bar(foo);
}

Error:

main.cpp:10:15: error: expected primary-expression before ‘int’
 type.func();
   ^
main.cpp:10:15: error: expected ‘;’ before ‘int’

The fix is to use the `template` keyword:

template
void bar(T& type)
{
type.template func();
}

Suggested error:

main.cpp: In function ‘void bar(T&)’:
main.cpp:13:10: error: need ‘template’ before ‘func’ because ‘T’ is a
dependent scope
 type.func();
  ^

[Bug c++/83136] New: static class template member: invalid application of ‘sizeof’ to incomplete type

2017-11-23 Thread steve.lorimer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83136

Bug ID: 83136
   Summary: static class template member: invalid application of
‘sizeof’ to incomplete type
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: steve.lorimer at gmail dot com
  Target Milestone: ---

Created attachment 42699
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42699&action=edit
example source code illustrating bug

Compiling the below example results in the following error

---

In instantiation of ‘struct Storage, 10ul>’:
   required from ‘struct Bar’
 error: invalid application of ‘sizeof’ to incomplete type ‘Bar’
  std::aligned_storage_t data[N];

---

#include 
#include 

template
struct Storage
{
std::aligned_storage_t data[N];
};

template
struct PoolObj
{
static void* operator new(std::size_t size)
{
return &T::pool.data[0];
}

static void operator delete(void* p, std::size_t size)
{
}
};

template
struct Bar : PoolObj>
{
static Storage, 10> pool;
};

template
Storage, 10> Bar::pool {};

int main()
{
Bar* b = new Bar();
delete b;

return 0;
}

[Bug c++/78177] New: adding -flto flags causes linker error "undefined reference to vtable"

2016-11-01 Thread steve.lorimer at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78177

Bug ID: 78177
   Summary: adding -flto flags causes linker error "undefined
reference to vtable"
   Product: gcc
   Version: 5.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: steve.lorimer at gmail dot com
  Target Milestone: ---

I have code which compiles and links fine.

I'm now trying to enable link-time optimizations, but adding -flto to my
compiler and linker flags is causing a linker error:

/usr/local/lib/libboost_thread.a(thread.o): \
In function `void
boost::throw_exception(boost::bad_lexical_cast
const&)':
   
thread.cpp:(.text._ZN5boost15throw_exceptionINS_16bad_lexical_castEEEvRKT_[_ZN5boost15throw_exceptionINS_16bad_lexical_castEEEvRKT_]+0x124):
\
undefined reference to `vtable for boost::bad_lexical_cast'

The only flag I've added is -flto.

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto" )
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -flto" )

To be clear:

Without -flto the app builds and links fine
With -flto (and no other changes), the app fails to link with the above error

I'm running version 5.4.0-6ubuntu1~16.04.2