[Bug c++/70435] New: section attribute of a function template is not honored.

2016-03-29 Thread kukyakya at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435

Bug ID: 70435
   Summary: section attribute of a function template is not
honored.
   Product: gcc
   Version: 5.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: kukyakya at gmail dot com
  Target Milestone: ---

namespace /* anonymous */
{
  [[gnu::section(".mysection")]]
  void regular_func() { }

  template 
  [[gnu::section(".mysection")]]
  void template_func() { }
} // namespace /* anonymous */

void (*ptr1)() = _func;
void (*ptr2)() = _func;


In the code above the section attribute is given to both of the regular
function and the function template, but the templated function is not placed in
.mysection but .text.

$ g++ -std=c++14 a.cpp -c && objdump -t a.o | grep -E "regular|template"
 l F .mysection 0007
_ZN12_GLOBAL__N_112regular_funcEv
 l F .text  0007
_ZN12_GLOBAL__N_113template_funcIiEEvv
~/temp/c++/function_template_section $ 


I also tried it with clang and clang put the function into .mysection as I
expected.


$ clang++ -std=c++14 a.cpp -c && objdump -t a.o | grep -E "regular|template"
 l F .mysection 0006
_ZN12_GLOBAL__N_112regular_funcEv
0010 l F .mysection 0006
_ZN12_GLOBAL__N_113template_funcIiEEvv

[Bug c++/69065] [C++11] multiple alignas specifiers

2016-01-02 Thread kukyakya at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69065

kukyakya at gmail dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #1 from kukyakya at gmail dot com ---
'alignas' specifier is not meant to be used in type declaration.
(http://stackoverflow.com/a/34006668/1030861)

Was not a bug.

Works as expected if used properly.
---
#include 

struct test1 {
alignas(int) alignas(double) char _; 
};

struct test2 {
alignas(double) alignas(int) char _; 
};

int main()
{
  std::cout << "alignof(int) is " << alignof(int) << std::endl;
  std::cout << "alignof(double) is " << alignof(double) << std::endl;
  std::cout << "alignof(test1) is " << alignof(test1) << std::endl;
  std::cout << "alignof(test2) is " << alignof(test2) << std::endl;
}
---
alignof(int) is 4
alignof(double) is 8
alignof(test1) is 8
alignof(test2) is 8
---

[Bug c++/69065] [C++11] multiple alignas specifiers

2016-01-02 Thread kukyakya at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69065

kukyakya at gmail dot com changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |---

--- Comment #2 from kukyakya at gmail dot com ---
Reopening the bug. It still does not accept 'alignas(pack...)' form.

---
#include 

struct test {
alignas(int, double) char _;
};

int main()
{
  std::cout << "alignof(int) is " << alignof(int) << std::endl;
  std::cout << "alignof(double) is " << alignof(double) << std::endl;
  std::cout << "alignof(test) is " << alignof(test) << std::endl;
}
---
$ g++ -Wall -Wextra -std=c++14 -pedantic -O2 a.cpp
a.cpp:4:13: error: expected ‘)’ before ‘,’ token
  alignas(int, double) char _;
 ^
a.cpp:4:13: error: expected ‘)’ before ‘,’ token
a.cpp:4:13: error: expected unqualified-id before ‘,’ token
---

[Bug c++/69065] New: [C++11] multiple alignas specifiers

2015-12-27 Thread kukyakya at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69065

Bug ID: 69065
   Summary: [C++11] multiple alignas specifiers
   Product: gcc
   Version: 5.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: kukyakya at gmail dot com
  Target Milestone: ---

http://en.cppreference.com/w/cpp/language/alignas (quoting it since I don't
have the C++11 standard documents now) states that `alignas` can be used in the
form of `alignas(pack...)`, but both g++ and clang++ fail to compile it.

struct alignas(int, double) test
{ };

So I tried to use multiple `alignas` specifiers, but got unexpected results.

#include 

// struct alignas(int, double) test
// { };

struct alignas(int) alignas(double) test1 { };
struct alignas(double) alignas(int) test2 { };

int main()
{
  std::cout << "alignof(int) is " << alignof(int) << std::endl;
  std::cout << "alignof(double) is " << alignof(double) << std::endl;
  // std::cout << "alignof(test) is " << alignof(test) << std::endl;
  std::cout << "alignof(test1) is " << alignof(test1) << std::endl;
  std::cout << "alignof(test2) is " << alignof(test2) << std::endl;
}

alignof(int) is 4
alignof(double) is 8
alignof(test1) is 8
alignof(test2) is 4

With clang++ I got

alignof(int) is 4
alignof(double) is 8
alignof(test1) is 8
alignof(test2) is 8

I'm not sure if it's okay to give multiple `alignas` specifiers, but I think it
should have the strictest alignment if it's okay. G++ seems to apply only the
latest `alignas` specifier.

[Bug lto/58203] memset/memcpy are discarded with -flto

2013-08-20 Thread kukyakya at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58203

--- Comment #1 from kukyakya at gmail dot com ---
Created attachment 30679
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=30679action=edit
Test case


[Bug lto/58203] New: memset/memcpy are discarded with -flto

2013-08-20 Thread kukyakya at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58203

Bug ID: 58203
   Summary: memset/memcpy are discarded with -flto
   Product: gcc
   Version: 4.8.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: lto
  Assignee: unassigned at gcc dot gnu.org
  Reporter: kukyakya at gmail dot com

It might be a duplicate of bug 51205 but it's happening again.

[test.cpp]
typedef void (*action_t)(const unsigned char*);

extern C void _start(action_t action)
{
  const unsigned char foo[256] = {};

  action(foo);
}

typedef __SIZE_TYPE__ size_t;

extern C
void*
//__attribute__((externally_visible)) // Workaround
memset(void* dst, int c, size_t len)
{
  unsigned char * d = (unsigned char*)dst;

  while(len--)
*d++ = c;

  return dst;
}

[error]
$ arm-none-linux-gnueabi-g++ -fno-exceptions -nostartfiles -static -nostdlib
-nodefaultlibs -flto test.cpp -o test
`memset' referenced in section `.text' of /tmp/cc7ooAE0.ltrans0.ltrans.o:
defined in discarded section `.text' of /tmp/ccVDnjy6.o (symbol from plugin)
collect2: error: ld returned 1 exit status

[versions]
arm-none-linux-gnueabi-g++ --version : 4.8.1
arm-none-linux-gnueabi-ld --version : 2.23.2