[Bug pch/56549] New: #pragma once ineffective with BOM in include file

2013-03-06 Thread yurivkhan at gmail dot com

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56549

 Bug #: 56549
   Summary: #pragma once ineffective with BOM in include file
Classification: Unclassified
   Product: gcc
   Version: 4.6.3
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: pch
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: yurivk...@gmail.com


Created attachment 29594
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29594
Minimal example demonstrating the problem

When an include file starts with a UTF-8 byte order mark and is included in a
precompiled header, it is not protected against repeated inclusion.

Environment:
 * Ubuntu 12.04 amd64
 * GCC 4.6.3 from Ubuntu repo

To reproduce:

$ unzip pragma-once-bom.zip
$ make

The contents of the archive are listed below for convenience of discussion.

Foo.h:
===
#pragma once

struct Foo {};
===

stable.h:
===
#include "Foo.h"
===

main.cpp:
===
#include "stable.h"

int main() { Foo foo; }
===

Makefile:
===
all: main.o

pragma-once.gch/c++: stable.h Foo.h
@test -d pragma-once.gch || mkdir pragma-once.gch
g++ -x c++-header -c stable.h -o pragma-once.gch/c++

main.o: main.cpp stable.h Foo.h pragma-once.gch/c++
g++ -c -include pragma-once -o main.o main.cpp

clean:
@rm -rf pragma-once.gch main.o
===

Expected behavior:

===
$ make
g++ -x c++-header -c stable.h -o pragma-once.gch/c++
g++ -c -include pragma-once -o main.o main.cpp
===

Observed behavior:

===
$ make
g++ -x c++-header -c stable.h -o pragma-once.gch/c++
g++ -c -include pragma-once -o main.o main.cpp
In file included from stable.h:1:0,
 from main.cpp:1:
Foo.h:3:8: error: redefinition of ‘struct Foo’
Foo.h:3:8: error: previous definition of ‘struct Foo’
make: *** [main.o] Error 1
===

Workarounds/observations:

* If the header file does not contain a BOM, the problem does not occur.
* With include guards instead of #pragma once, the problem does not occur.
* In a real project, changing an #include  to #include
 in the precompiled header stable.h, or changing an #include
 to #include "Foo.h" in a different header included by stable.h,
also fixes the immediate problem.


[Bug pch/56549] #pragma once ineffective with BOM in include file

2013-03-06 Thread yurivkhan at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56549



--- Comment #1 from Yuri Khan  2013-03-06 09:52:01 
UTC ---

Also reproduced on 4.7.2.


[Bug libstdc++/66485] New: std::string single-character assignment operator

2015-06-10 Thread yurivkhan at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66485

Bug ID: 66485
   Summary: std::string single-character assignment operator
   Product: gcc
   Version: 4.8.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yurivkhan at gmail dot com
  Target Milestone: ---

gcc’s implementation of std::basic_string contains a non-standard and very
surprising operator= which accepts a single character or anything that is
implicitly castable thereto.

To reproduce:

===
#include 
#include 

int main()
{
std::string s;
s = 42;
std::cout << s << "\n";
}
===

$ g++ --version
g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2[…]

$ g++ test.cpp
(with any of -std= variations, with or without -Wall -pedantic)

Observed behavior: compiles, runs, outputs a single character * (asterisk).

Expected behavior: compilation error, because the standard does not define any
such operator=.

[Bug libstdc++/66485] std::string single-character assignment operator

2015-06-10 Thread yurivkhan at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66485

--- Comment #2 from Yuri Khan  ---
Right, I somehow missed it. The overload is there. Sorry for the noise.