杂项问题...... [英] Misc Qns...

查看:54
本文介绍了杂项问题......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1。将简单地取一个非对齐变量的地址(但不是引用它的
)产生未定义的行为?

如果确实如此,是否有任何已知的体系结构失败?


2. char [MB_CUR_MAX]是否足够大以容纳任何仲裁多字节字符

在初始移位状态中开始和结束?我没有相当

了解

标准(WG14 / N869)7.1.1#7(脚注141)。


3必须是默认C上的可移植字符。在扩展区域设置上使用时,locale具有相同的

位表示? IOW,必须扩展

locales向后兼容C locale?

4.多字节字符串中的移位字节序列的第一个字节是否可以与可移植字符集中的任何字符具有相同的表示形式

当初始班次状态为
时?


谢谢。

1. Will simply taking the address of a non-aligned variable (but not
deferencing it) produce undefined behavior?
If it does, are there any known architectures on which this fails?

2. Is char[MB_CUR_MAX] large enough to hold any arbitary multibyte char
beginning and ending in the initial shift state? I didnt quite
understand
the standard (WG14/N869) 7.1.1 #7 (footnote 141).

3. Must the portable characters on the default "C" locale have the same
bit representation when used on an extended locale? IOW, must extended
locales be backwards compatible with the "C" locale?

4. Can the first byte of a shift-byte sequence in a multibyte string have
the same representation as any character in the portable character set
when
in the initial shift state?

Thanks.

推荐答案

Jin写道:
Jin wrote:
1.简单地取一个非对齐变量的地址(但不是引用它)会产生未定义的行为吗?
不符合_Standard_。对齐限制是

实现细节,而不是标准之一。我的理解是

访问未对齐的数据只需要处理器获取更多的数据



如果确实如此,那么有没有这个失败的已知架构?
1. Will simply taking the address of a non-aligned variable (but not
deferencing it) produce undefined behavior? Not according to the _Standard_. Alignment restrictions are an
implementation detail, not one of the standard. My understanding is
that accessing data that is not aligned will just take more fetches
by the processor.
If it does, are there any known architectures on which this fails?



可能,但我不知道所有的架构。


[snip - multibyte char问题]


-

Thomas Matthews


C ++新闻组欢迎辞:
http://www.slack.net/~shiva/welcome.txt

C ++常见问题: http:// www。 parashift.com/c++-faq-lite

C常见问题: http://www.eskimo.com/~scs/c-faq/top.html

alt.comp.lang.learn .c-c ++ faq:
http://万维网.raos.demon.uk / acllc -c ++ / faq.html

其他网站:
http://www.josuttis.com - C ++ STL图书馆书籍


Could be, but I don''t know all the architectures.

[snip -- multibyte char issues]

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book


Thomas Matthews写道:
Thomas Matthews wrote:

Jin写道:

Jin wrote:
1.将简单地取一个非对齐变量的地址(但不是
引用它)产生未定义的行为?
1. Will simply taking the address of a non-aligned variable (but not
deferencing it) produce undefined behavior?


不符合_Standard_。对齐限制是一个
实现细节,而不是标准之一。


Not according to the _Standard_. Alignment restrictions are an
implementation detail, not one of the standard.




No.

代码依赖于没有对齐要求

有未定义的行为。

当你的代码依赖于

时没有对齐要求,

你所知道的是要么它会起作用,要么它不会。

如果它因违反校准要求而失败,那么

那么你就没有了想法它将如何失败:那是'未定义的行为。


-

pete



No.
Code which relies on there being no alignment requirements
has undefined behavior.
When you have code that relies on
there being no alignment requirements,
all you know is that either it will work or it won''t.
If it''s going to fail from violating alignment requirements,
then you have no idea how it will fail: that''s undefined behavior.

--
pete


在文章< op ************** @ news.starhub.net.sg> ;, Jin< - >写道:
In article <op**************@news.starhub.net.sg>, Jin <-> wrote:
1。简单地使用非对齐变量的地址(但不是引用它)会产生未定义的行为吗?
如果确实如此,是否有任何已知的架构失败?
1. Will simply taking the address of a non-aligned variable (but not
deferencing it) produce undefined behavior?
If it does, are there any known architectures on which this fails?



如果不调用未定义的

行为,你会如何生成一个非对齐变量?

(这是执行的责任)确保任何变量

它给你正确对齐,所以如果指向它们

给你一个未对齐的指针,表明

实施。)

dave


-

Dave Vandervies dj ****** @ csclub.uwaterloo.ca


注意printf()可能非常在微波炉上很有用。

- comp.lang.c中的理查德希思菲尔德



How would you generate a non-aligned variable without invoking undefined
behavior?
(It''s the implementation''s responsibility to make sure any variables
it gives you are aligned appropriately, so if taking a pointer to them
gives you an unaligned pointer that would indicate a problem with the
implementation.)
dave

--
Dave Vandervies dj******@csclub.uwaterloo.ca

Note that printf() could be very useful on a microwave oven.
--Richard Heathfield in comp.lang.c


这篇关于杂项问题......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆