簡體   English   中英

C ++標准歧義

[英]C++ standard ambiguity

據我在標准中看到的,以下代碼有效。 它在MSVC1025中編譯。

const struct omg;
struct omg volatile;

int main()
{
    return 0;
}

在這些聲明中,限定符constvolatile似乎是沒有目的的。 它們既無助於編譯器和程序員,也無濟於事。

該標准似乎並不打算消除這些“空的模棱兩可”。 在空申報的情況下; ,這是明確允許的。

在預處理之后,是否還有其他令牌的情況與表達式的含義無關?

clanggcc都使用-pedantic-errors拒絕此代碼。 clang提供以下錯誤:

error: 'const' is not permitted on a declaration of a type [-Werror,-Wmissing-declarations]
const struct omg;
^

error: 'volatile' is not permitted on a declaration of a type [-Werror,-Wmissing-declarations]

C ++標准草案7.1.6.1的cv限定詞[dcl.type.cv]說:

[...]如果cv限定詞出現在decl-specifier-seq中,則聲明的init-declarator-list不得為空。[...]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM