異議あり！言語法律家の物語(Objection! A Language Lawyer Story)

# Objection! A Language Lawyer Story

<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Objection! A Language Lawyer Story<br><br>🔊 for my awful voice acting <a href="https://t.co/GmZqQShtEG">pic.twitter.com/GmZqQShtEG</a></p>&mdash; Sy Brand (@TartanLlama) <a href="https://twitter.com/TartanLlama/status/1283816537778982914?ref_src=twsrc%5Etfw">July 16, 2020</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

元ネタ：ゲーム「[逆転裁判](https://ja.wikipedia.org/wiki/%E9%80%86%E8%BB%A2%E8%A3%81%E5%88%A4)シリーズ」（英語版は"Ace Attorney"）より。プログラミング言語仕様に基づいて議論する人々は、俗に [言語法律家(language lawyer)](https://qiita.com/yohhoy/items/f3e361aa5897e65757b4) とよばれる。

登場人物（括弧内は日本語版でのキャラクタ名）：

- [Phoenix Wright](https://en.wikipedia.org/wiki/Phoenix_Wright)（成歩堂 龍一; なるほどう りゅういち), Nick[^nick]
- [Miles Edgeworth](https://en.wikipedia.org/wiki/Miles_Edgeworth)（御剣 怜侍; みつるぎ れいじ）
- [Maya Fey](https://en.wikipedia.org/wiki/Maya_Fey)（綾里 真宵; あやさと まよい）
- Judge（裁判長）

[^nick]: Phoenix Wrightのニックネーム。


## Script

Phoenix: I would like to present to the compiler: this code.

```c++
struct foo{};
constexpr foo x;

int main() {
    []{ return x; }();
}
```

Phoenix: As you can see, it should compile...

**[Objection!]**

Edgeworth: You fool.

Phoenix: Oh? You've found a problem?

Edgeworth: You forget to initialize x.

**[Take that!]**

Phoenix: You're wrong!
Phoenix: [[class.ctor.default]/4](https://timsong-cpp.github.io/cppwp/n4861/class.default.ctor#4)[^cls-def-ctor] says the default constructor satisfies the conditions for a constexpr constructor!

[^cls-def-ctor]: セクションラベルは [class.ctor.default] ではなく [class.default.ctor] が正しい。

Edgeworth: Impossible!

Gallery: He's right!

Judge: Order!
Judge: I'm afraid the defense is correct. I think this code should compile...

**[Hold it!]**

Edgeworth: You almost had me there, Wright.

Phoenix: Does this mean you found something else?

Edgeworth: Look at the lambda.
Edgeworth: You forgot to capture x!

Phoenix: What!? No!

Judge: You're quite right there!
Judge: I'm ready to issue my verdict. This code shouldn't compile...

**[Hold it!]**

Maya: .........
Maya: You've got this, Nick, just look at the standard.

Phoenix: I've got to bluff while I find the right paragraph.
Phoenix: If you look at [[expr.prim.lambda.capture]](https://timsong-cpp.github.io/cppwp/n4861/expr.prim.lambda.capture)...

Edgeworth: That section is massive, show me the paragraph!

Phoenix: I found it!
Phoenix: If you look at [paragraph 8](https://timsong-cpp.github.io/cppwp/n4861/expr.prim.lambda.capture#8) you'll see...
Phoenix: that you don't need to capture entities which are not odr-used!

**[Objection!]**

Edgeworth: But x is odr-used!

**[Objection!]**

Phoenix: No, because it's constexpr!

Edgeworth: ...NO!!!

Judge: Can someone explain what odr-use is?

Phoenix: It's when you use a variable in a way which requires a definition.
Phoenix: [[basic.def.odr]/4.2](https://timsong-cpp.github.io/cppwp/n4861/basic.def.odr#4.2) says this code with a constexpr variable does not constitute odr-use.

Judge: Is this right, Edgeworth?

Edgeworth: .........

Judge: I'll take that as a yes.
Judge: I can now judge that this code...
Judge: Compiles.