Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A3-3-2 Contradictory examples?
#1
In Rule A3-3-2, there's an example with "class A" which has a non-constexpr, user-defined constructor. 

On line 31, we have a compliant example:
Code:
A instance{}; // Compliant - constant (value) initialization

However, on line 37 it's no longer compliant:

Code:
static A a{}; // Non-compliant - A’s default c’tor is not constexpr

There seems to be a contradiction here. Either the code is doing value initialization, or it's calling a constructor, but not both. Which one is it?

In other words, it seems like both examples are doing the same thing, so both should either be compliant or non-compliant. Would you agree?
Reply
#2
This appears to be an error, thanks for pointing it out.

Line 31 should be non-compliant, for the same reason as line 37
Posted by and on behalf of
the MISRA C++ Working Group
Reply
#3
(28-03-2025, 01:49 PM)misra cpp Wrote: This appears to be an error, thanks for pointing it out.

Line 31 should be non-compliant, for the same reason as line 37

I agree, thanks for the clarification!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)