[Bug c++/95773] New: [[nodiscard]] attribute is ignored for calls to overridden functions

2020-06-19 Thread vladimir.krivopalov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95773

Bug ID: 95773
   Summary: [[nodiscard]] attribute is ignored for calls to
overridden functions
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vladimir.krivopalov at gmail dot com
  Target Milestone: ---

The following code compiles fine with GCC 10.1.0 but fails with Clang 10.0.0 :


struct Base {
[[nodiscard]] virtual int f() = 0;
};

struct Derived : Base {
[[nodiscard]] int f() override {
return 1135;
}
};

int main()
{
Derived d;
Base& b = d;
b.f();
return 0;
}


# g++ -Wall -Werror -Wextra -std=c++17 nodiscard.cpp -o nodiscard
# clang++ -Wall -Werror -Wextra -std=c++17 nodiscard.cpp -o nodiscard
nodiscard.cpp:15:5: error: ignoring return value of function declared with
'nodiscard' attribute [-Werror,-Wunused-result]
b.f();
^~~
1 error generated.

[Bug c++/82304] New: GCC compiles constexpr function with double reinterpret_cast in a constant context

2017-09-22 Thread vladimir.krivopalov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82304

Bug ID: 82304
   Summary: GCC compiles constexpr function with double
reinterpret_cast in a constant context
   Product: gcc
   Version: 7.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vladimir.krivopalov at gmail dot com
  Target Milestone: ---

The following code compiles fine with GCC (-std=c++14) although normally it
should be rejected:

#include 
inline constexpr const char* testfunc(const char* p)
{
return reinterpret_cast (
   reinterpret_cast(p));
}

int main(int argc, char** argv) {
static constexpr const char* second = testfunc("Hello");
}

The C+14 standard prohibits use of reinterpret_cast in constexpr functions:
[expr.const]/2.11 and [expr.const]/2.13

[Bug libstdc++/57350] std::align missing

2014-02-01 Thread vladimir.krivopalov at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57350

Vladimir Krivopalov  changed:

   What|Removed |Added

 CC||vladimir.krivopalov at gmail 
dot c
   ||om

--- Comment #3 from Vladimir Krivopalov  
---
Greetings,

Any chance to get std::align() implementation included in the coming GCC
releases?
What needs to be done for that?


[Bug libstdc++/57350] std::align missing

2014-02-01 Thread vladimir.krivopalov at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57350

--- Comment #6 from Vladimir Krivopalov  
---
(In reply to David Krauss from comment #5)
> Just re-reading now, std::size_t should be std::uintptr_t, but I don't see
> anything else that could cause UB. The bitwise "negative" arithmetic should
> be OK because it's all on unsigned values.
> 
> And if GNU style doesn't allow auto, those should just be uintptr_t or
> size_t as appropriate.

This code looks fine to me at my best knowledge of expected std::align()
behaviour.

I also tried it against the artificial test case described at
https://stackoverflow.com/questions/16305311/usage-issue-of-stdalign and it
doesn't re-align the already aligned pointer.

Not sure if auto keyword is prohibited by GCC internal code style, perhaps
someone from GCC devs could help on that.

Thank you for preparing the fix, David!