究竟什么“IB”和“UB”意思? [英] What exactly do "IB" and "UB" mean?

查看:608
本文介绍了究竟什么“IB”和“UB”意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过IB和UB这几个术语,特别是在C ++的上下文中。我试过谷歌搜索,但显然这两个字母的组合看到很多用途。 :P

I've seen the terms "IB" and "UB" used several times, particularly in the context of C++. I've tried googling them, but apparently those two-letter combinations see a lot of use. :P

所以,我问你......当他们说他们是坏事时,他们是什么意思?

So, I ask you...what do they mean, when they're said as if they're a bad thing?

推荐答案

IB:实现定义的行为标准让它由特定的编译器/平台定义精确的行为,

IB: Implementation-defined behaviour. The standard leaves it up to the particular compiler/platform to define the precise behaviour, but requires that it be defined.

使用实现定义的行为可能是有用的,但是会使代码更不便于移植。

Using implementation-defined behaviour can be useful, but makes your code less portable.

UB:未定义的行为。标准没有指定调用未定义行为的程序的行为。也被称为鼻恶魔,因为理论上它可以使恶魔飞出你的鼻子。

UB: Undefined behaviour. The standard does not specify how a program invoking undefined behaviour should behave. Also known as "nasal demons" because theoretically it could make demons fly out of your nose.

使用未定义的行为几乎总是一个坏主意。即使它似乎有时工作,对环境,编译器或平台的任何更改可以随机破坏您的代码。

Using undefined behaviour is nearly always a bad idea. Even if it seems to work sometimes, any change to environment, compiler or platform can randomly break your code.

这篇关于究竟什么“IB”和“UB”意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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