X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=SrTS2VYQsTJjj3vm Bq0HZgMCuXjvoqomHYNktuvPuTAX+tZrhBHdP+5tD+5I8hPqvQDncGBoIgVxfU36 ziAudHEKZjvtSiDIFFkS3vBakGDCVq0IgXtkZAVbGDRuZUWPnT3NHQdUkJWtQRc+ QSeg0AtXPd1xFyDv6EPMMhOExCs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=oM21/QjzMLzHptUjtOZNUo PACDg=; b=SAV3Z5xjC6cM5Cz6fRkjKDl7OBGAGLaHbTE5LYHnPzGPzmlnJR/0fu 44AmWNXH1VcVJwlqgvoZoK4yz7/VxG1VWsaW5UQtFnps8zHkLvheylqYtXx3uFvr bUGJh0eO+9c+DupfaxdLlzjozF2aLTpAV4MMzsMADqHxLySRnZaJY= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,KAM_NUMSUBJECT,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy= X-HELO: smtp-out-no.shaw.ca Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca Subject: Re: [BUG] try..catch does not work if compiled with clang 8.0 To: cygwin AT cygwin DOT com References: <000701d5b4bd$42c086f0$c84194d0$@samsung.com> <016d01d5b5b5$47d6b8a0$d78429e0$@samsung.com> From: Brian Inglis Openpgp: preference=signencrypt Message-ID: <9f6fe40a-2dda-211f-57bc-d8b05413db4a@SystematicSw.ab.ca> Date: Wed, 18 Dec 2019 10:46:57 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <016d01d5b5b5$47d6b8a0$d78429e0$@samsung.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes On 2019-12-18 08:10, Pavel Fedin wrote: > Well, it turned out more complicated than i thought. Here is the reduced > reproducer: > --- cut catch_test.cpp --- > #include > #include > #include > #include > #include > > void from_file(const std::string &filepath, std::vector &data); > > int main() > { > try > { > std::vector data; > > from_file("no_such_file.bin", data); > std::cout << "Success ???" << std::endl; > } > catch (const std::exception &e) > { > std::cout << "std::exception: " << e.what() << std::endl; > } > > return 0; > } > --- cut catch_test.cpp --- > --- cut catch_test_2.cpp --- > #include > #include > #include > #include > #include > > using namespace std; > > template void from_file_impl(const string &filepath, vector &data) > { > // data.clear(); > > std::ifstream ifs(filepath.c_str()); > if (ifs.rdstate() & ifstream::failbit) > { > throw std::runtime_error("Error in reading " + filepath); > } > > /* T buffer; > > while (ifs.read(reinterpret_cast(&buffer), sizeof(T))) > { > data.push_back(buffer); > }*/ > } > > void from_file(const string &filepath, vector &data) { from_file_impl(filepath, data); } > --- cut catch_test_2.cpp --- > --- cut console log --- > CORP+p DOT fedin AT P-FEDIN01 /cygdrive/d/Projects/Test > $ clang++-8 catch_test.cpp catch_test_2.cpp -g -o catch_test > > CORP+p DOT fedin AT P-FEDIN01 /cygdrive/d/Projects/Test > $ ./catch_test > > CORP+p DOT fedin AT P-FEDIN01 /cygdrive/d/Projects/Test > $ g++.exe catch_test.cpp catch_test_2.cpp -g -o catch_test > > CORP+p DOT fedin AT P-FEDIN01 /cygdrive/d/Projects/Test > $ ./catch_test > > CORP+p DOT fedin AT P-FEDIN01 /cygdrive/d/Projects/Test > $ clang++-5.0 catch_test.cpp catch_test_2.cpp -g -o catch_test > > CORP+p DOT fedin AT P-FEDIN01 /cygdrive/d/Projects/Test > $ ./catch_test > std::exception: Error in reading no_such_file.bin > > CORP+p DOT fedin AT P-FEDIN01 /cygdrive/d/Projects/Test > $ > --- cut console log --- > > So, the problem actually reproduces with both clang 8 and gcc (7.4.0 on my > system). clang 5 works fine. Confirmed with clang++ 8, but WJFFM with g++ 7.4.0 and reports exception (below). Warnings from clang++ and g++: $ clang++-8/5.0 -g -Og -Wpedantic -Wall -Wextra -o try-catch-stc-1{,.cpp} try-catch-stc-2.cpp try-catch-stc-2.cpp:9:78: warning: unused parameter 'data' [-Wunused-parameter] template void from_file_impl(const string &filepath, vector &data) ^ 1 warning generated. $ g++ -g -Og -Wpedantic -Wall -Wextra -o try-catch-stc-1{,.cpp} try-catch-stc-2.cpp try-catch-stc-2.cpp: In instantiation of ‘void from_file_impl(const string&, std::vector&) [with T = signed char; std::string = std::basic_string]’: try-catch-stc-2.cpp:19:34: required from here try-catch-stc-2.cpp:9:78: warning: unused parameter ‘data’ [-Wunused-parameter] template void from_file_impl(const string &filepath, vector &data) $ ./try-catch-stc-1 exception: Error in reading no_such_file.bin > So, a Windows exception is reported, then the whole thing silently quits. > I have an impression that it has to do with the bug I previously reported > (and someone here claimed he could reproduce it) Please provide a link to the Cygwin ML message; is it this, confirmed by Takashi Yano: https://cygwin.com/ml/cygwin/2019-10/msg00038.html -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple