Discussion:
Isn't the [decl.init]/12.2 redundant?
(too old to reply)
m***@gmail.com
2018-11-02 10:52:24 UTC
Permalink
Hello,
If an indeterminate value of unsigned narrow character type or std​::​byte
type is produced by the evaluation of the right operand of a simple
assignment operator ([expr.ass]) whose first operand is an lvalue of
unsigned narrow character type or std​::​byte type, an indeterminate value
replaces the value of the object referred to by the left operand.

e.g.
```
void foo()
{
unsigned char c;

// These
unsigned char d = c;
std::byte b = (std::byte)d;
std::byte b2 = b;
}
```

Correct me if I am wrong, but aren't the last three initializations just a
copy initializations? If so, two following paragraphs successfully cover
the [decl.init]/12.2, so it can be removed, right?

[decl.init]/12.3 (http://eel.is/c++draft/dcl.init#12.3)
If an indeterminate value of unsigned narrow character type is produced by
the evaluation of the initialization expression when initializing an object
of unsigned narrow character type, that object is initialized to an
indeterminate value.

[decl.init]/12.4 (http://eel.is/c++draft/dcl.init#12.4)
If an indeterminate value of unsigned narrow character type or std​::​byte
type is produced by the evaluation of the initialization expression when
initializing an object of std​::​byte type, that object is initialized to
an indeterminate value.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Nicolas Lesser
2018-11-02 11:43:16 UTC
Permalink
Post by m***@gmail.com
Hello,
If an indeterminate value of unsigned narrow character type or
std​::​byte type is produced by the evaluation of the right operand of a
simple assignment operator ([expr.ass]) whose first operand is an lvalue of
unsigned narrow character type or std​::​byte type, an indeterminate value
replaces the value of the object referred to by the left operand.
e.g.
```
void foo()
{
unsigned char c;
// These
unsigned char d = c;
std::byte b = (std::byte)d;
std::byte b2 = b;
No, not these. p12.2 refers to assignment expressions:

unsigned char d;
d = c; // this

}
Post by m***@gmail.com
```
Correct me if I am wrong, but aren't the last three initializations just a
copy initializations?
Yes

Iff so, two following paragraphs successfully cover the [decl.init]/12.2,
Post by m***@gmail.com
so it can be removed, right?
No, because as said before, p12.2 refers to expressions, not
initializations.
Post by m***@gmail.com
[decl.init]/12.3 (http://eel.is/c++draft/dcl.init#12.3)
If an indeterminate value of unsigned narrow character type is produced
by the evaluation of the initialization expression when initializing an
object of unsigned narrow character type, that object is initialized to an
indeterminate value.
[decl.init]/12.4 (http://eel.is/c++draft/dcl.init#12.4)
If an indeterminate value of unsigned narrow character type or
std​::​byte type is produced by the evaluation of the initialization
expression when initializing an object of std​::​byte type, that object is
initialized to an indeterminate value.
--
---
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at
https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
m***@gmail.com
2018-11-05 17:33:10 UTC
Permalink
Ahh, I see. Thank you for explanation.

W dniu piątek, 2 listopada 2018 12:43:28 UTC+1 uÅŒytkownik Nicolas Lesser
Post by Nicolas Lesser
Post by m***@gmail.com
Hello,
If an indeterminate value of unsigned narrow character type or
std​::​byte type is produced by the evaluation of the right operand of a
simple assignment operator ([expr.ass]) whose first operand is an lvalue of
unsigned narrow character type or std​::​byte type, an indeterminate value
replaces the value of the object referred to by the left operand.
e.g.
```
void foo()
{
unsigned char c;
// These
unsigned char d = c;
std::byte b = (std::byte)d;
std::byte b2 = b;
unsigned char d;
d = c; // this
}
Post by m***@gmail.com
```
Correct me if I am wrong, but aren't the last three initializations just
a copy initializations?
Yes
Iff so, two following paragraphs successfully cover the [decl.init]/12.2,
Post by m***@gmail.com
so it can be removed, right?
No, because as said before, p12.2 refers to expressions, not
initializations.
Post by m***@gmail.com
[decl.init]/12.3 (http://eel.is/c++draft/dcl.init#12.3)
If an indeterminate value of unsigned narrow character type is produced
by the evaluation of the initialization expression when initializing an
object of unsigned narrow character type, that object is initialized to an
indeterminate value.
[decl.init]/12.4 (http://eel.is/c++draft/dcl.init#12.4)
If an indeterminate value of unsigned narrow character type or
std​::​byte type is produced by the evaluation of the initialization
expression when initializing an object of std​::​byte type, that object is
initialized to an indeterminate value.
--
---
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at
https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Continue reading on narkive:
Loading...