[Bug c++/77263] New: comment /* */ is ignored in some cases
bremende55 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Aug 16 09:56:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77263
Bug ID: 77263
Summary: comment /* */ is ignored in some cases
Product: gcc
Version: 6.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: bremende55 at gmail dot com
Target Milestone: ---
The following code compiles and gives the correct result:
#include <iostream>
#include <regex>
#include <string>
int main() {
std::string astring("// x /* meaningless comment start ");
// /*
std::string result = std::regex_replace(
astring, std::regex("//[^\n]*/\\*"), "ZZ ");
std::cout << "result = " << result << '\n';
// expected: ZZ meaningless comment start
// */
std::cout << "astring = " << astring << '\n';
}
BUT when I comment out the lines in the middle, i.e.
#include <iostream>
#include <regex>
#include <string>
int main() {
std::string astring("// x /* meaningless comment start ");
/*
std::string result = std::regex_replace(
astring, std::regex("//[^\n]*/\\*"), "ZZ ");
std::cout << "result = " << result << '\n';
// expected: ZZ meaningless comment start
*/
std::cout << "astring = " << astring << '\n';
}
the compile detects errors in the out-commented code.
g++ -v
yields:
Es werden eingebaute Spezifikationen verwendet.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/lib/gcc/x86_64-pc-linux-gnu/6.1.0/lto-wrapper
Ziel: x86_64-pc-linux-gnu
Konfiguriert mit: ../gcc-6.1.0/configure --enable-languages=c,c++
Thread-Modell: posix
gcc-Version 6.1.0 (GCC)
More information about the Gcc-bugs
mailing list