मुझे पूरा यकीन है कि विजुअल सी ++ 2015 में एक बग है, लेकिन मुझे 100% यकीन नहीं है।स्ट्रिंग शाब्दिक concatenation (अनुवाद के सी ++ 11 चरण 6) के लिए सही व्यवहार
कोड:
// Encoding: UTF-8 with BOM (required by Visual C++).
#include <stdlib.h>
auto main()
-> int
{
auto const s = L""
" is not in the Unicode BMP!";
return s[0] > 256? EXIT_SUCCESS : EXIT_FAILURE;
}
जी के साथ ++ परिणाम:
[H:\scratchpad\simple_text_io] > g++ --version | find "++" g++ (i686-win32-dwarf-rev1, Built by MinGW-W64 project) 6.2.0 [H:\scratchpad\simple_text_io] > g++ compiler_bug_demo.cpp [H:\scratchpad\simple_text_io] > run a Process exit code = 0. [H:\scratchpad\simple_text_io] > _
विज़ुअल सी के साथ ++ परिणाम:
[H:\scratchpad\simple_text_io] > cl /nologo- 2>&1 | find "++" Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86 [H:\scratchpad\simple_text_io] > cl compiler_bug_demo.cpp /Feb compiler_bug_demo.cpp compiler_bug_demo.cpp(8): warning C4566: character represented by universal-character-name '\U00010437' cannot be represented in the current code page (1252) [H:\scratchpad\simple_text_io] > run b Process exit code = 1. [H:\scratchpad\simple_text_io] > _
कोई यूबी शामिल है, और नहीं, संकलक सही ढंग से कार्य जो करता है, तो ?
परिशिष्ट:
व्यवहार दोनों compilers के लिए अपरिवर्तित है लोअरकेस ग्रीक पीआई उपयोग करते हैं, “ π ”, जो बीएमपी में है, ताकि कोई फर्क नहीं लगता है।
मैं कहने वाला था "वीसी ++ गलत है क्योंकि §2.14.5, आइटम 13", लेकिन चरित्र के आस-पास के नियम हमेशा मुझे भ्रमित करते हैं। – molbdnilo
वीएस 2015 अपडेट 3 ('माइक्रोसॉफ्ट (आर) सी/सी ++ एक्सप्लोरिंग कंपाइलर संस्करण 1 9 .00.24213.1 x86' के लिए) इसे कोई त्रुटि या चेतावनी के साथ संकलित करता है; मैंने Emacs में 'utf-8-unix' कोडिंग सिस्टम में फ़ाइल को सहेजा। वीएस का कौन सा संस्करण आपके पास विशेष रूप से है? – legends2k
@ legends2k: प्रश्न में उदाहरण संस्करण सूचीबद्ध करता है। –